Xpath summary

Xpath: uses path expressions to select nodes / node set XML document.

- path expressions: from one node to another node or XML 

                     The step of writing to a group of nodes "/" separated

               Each step is composed of three components:

             Axis test node test node descriptor 

About Xpath:

(1) use path expressions to navigate in XML documents

(2) contains a standard library

(3) is a major element in XSLT

(4) is a W3C standard

Details:

1, Node: namespace element attributes text annotation and document processing instruction (root) node

2, the syntax:

      1> Select node: nodename byte select all points of this node

                       / Select from the root node

                      // select a document from the current node in the node match regardless of their location

                      . Select the current node

                      .. select the parent node of the current node

                      @ Select Properties

3, predicate (Predicates): used to find a particular node or a node containing a specific value   by [] represents

[1]

[last()]

[last()-1]

[Position () <3] to select two top

[@Lang] Select a node attribute named lang

// title [@ lang = 'eng'] Select all title elements and these elements have a lang attribute value eng 

 

Select the unknown node

Wildcards can be used to select xpath unknown XML element 

* Matches any element node

@ * Matches any attribute node

node () matches any type node

Example:

// title [@ *] select all the title elements with attributes

 

Select several nodes

  Use "|" Operator

Operators:! + - * | div (division) = = or and mod (modulo)

 

Select nodes;

IE:  XmlDoc.selectNodes(xpath);

Other: XmlDoc.evaluate (xpath, xmlDoc, null, XpathResult.ANTTYPE, NULL);

 

 

 

 

                      

Guess you like

Origin www.cnblogs.com/truda/p/11118973.html