• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XML question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: XML question
      • From: "Mark J. Reed" <email@hidden>
References: 
 >XML question (From: Ruth Bygrave <email@hidden>)
 >Re: XML question (From: "Christian Roth" <email@hidden>)
 >Re: XML question (From: Ruth Bygrave <email@hidden>)

  • Prev by Date: Re: acgi dispatcher problems...
  • Next by Date: Re: acgi dispatcher problems...
  • Previous by thread: Re: XML question
  • Next by thread: Re: XML question
  • Index(es):
    • Date
    • Thread