Re: XML question
Re: XML question
- Subject: Re: XML question
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 5 Dec 2006 10:01:19 -0500
In the Document Object Model view of an XML document, attributes are
children of their element, just as child elements are. So in the case
of something like this:
<book name="Some Book">
<author>That Guy</author>
<series>A 5-book Trilogy</series>
<position>4</position>
</book>
You get a DOM tree like this:
[Element: book]
+--------------------------------+----------------------------+--------------------------+
[Attribute: name="name", [Element: author] [Element: series]
[Element: position]
value="Some Book"] +
+ +
[Text: That Guy] [Text: A
5-book Trilogy] [Text: 4]
So "author" and "name" are both children of "book", distinguished only
by their "node type" ("element" vs. "attribute"). In an XPath
expression, you make that distinction by prepending a '@' to a name to
indicate that you mean an attribute.
An attribute is contained in one node, but an element is not; the text
values of the author, series, and position elements are another level
down in the tree as text nodes. You get to them with an XPath
expression like this:
/book/author/text()
Here, the () is what indicates that you're looking for a text node,
rather than an element node whose tag name is "text".
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden