XPATH



techstore
LQ Net Home















XPATH

print    Printer Friendly Page

XPATH uses patterns to locate nodes on an XML tree.
Sample XML
This XML is the sample used for the XPATH examples.
<PEOPLE>
<PERSON ID=12345>
<NAME>Joe Smith</NAME>
<ADDRESS>
<STREET1234 Main Street</STREET>
<CITY>Anytown</CITY>
<STATE>IL</STATE>
<ZIP>60606</ZIP>
</ADDRESS>
</PERSON>
</PEOPLE> n>


XPATH Elements
PERSON or //PERSON Any element named "PERSON"
/PEOPLE Elements named "PEOPLE" that are children of the root node.
PERSON/NAME Elements named "NAME" that are children of the element named "PERSON".
/PEOPLE/PERSON Elements named "PEOPLE" that are children of the element named "PEOPLE" which is a child of the root element.
PEOPLE//NAME Elements named "NAME" that have the element "PEOPLE" as an ancestor.
PEOPLE/*/NAME Elements named "NAME" that have the element "PEOPLE" as an grandparent (Parent of its parent).
PERSON[NAME] Elements named "PERSON" that have a child the element named "NAME".


XPATH Nodes

ROOT Node
  • The ROOT node contains the entire XML document.
  • In XPATH, the ROOT node is designated as a slash /.
  • The ROOT node does not have a PARENT node.
  • The ROOT node has child nodes. One is the document element.
  • The ROOT node can also have comments and processing instructions as child elements.


ELEMENT Nodes
  • There is an xpath ELEMENT for every element in the XML document.
  • An ELEMENT node's children include:
    • text nodes
    • element nodes
    • comment nodes
    • processing instructions
    • text nodes
   Today's News





Office Depot, Inc

Tech Depot - An Office Depot Co.



Overstock.com, Inc.

























Copyright © 2006-2008, LQ Systems,Inc. All rights reserved.