The following example shows how to specify an axis in an XPath query. All XPath queries in these examples are specified on the ING architecture contained in SampleSchema1.xml. For information about the architecture in this example, see the example XPath query. The following example shows how to specify an axis in an XPath query. All XPath queries in these examples are specified on the ING architecture contained in SampleSchema1.xml. For information about the architecture in this example, see the example XPath query.
Example
A. retrieve the child elements of the context node
This XPath queries all of the selected context nodes Child element:
/Child: Employee
In this query, child is the axis, and Customer is the node test (if Customer is Node, the test is TRUE, because Is the primary node type associated with the child axis ).
Child is the default axis. Therefore, you can write the query as follows:
/Employee
Test the XPath query on the ING architecture
Create the following template (MyTemplate. xml) and save it in the directory associated with the template virtual name.
/Employee
The following URL execution template:
http://IISServer/VirtualRoot/template/MyTemplate.xml
You can directly specify the XPath query in the URL:
http://IISServer/nwind/schema/SampleSchema1.xml/child::Customer?root=root
The virtual name schema is of the schema type. The schema file is stored in the directory associated with the schema type virtual name. The root parameter is used to specify the top-level element for the obtained XML document (root can be any value ).
Some result sets executed by the template are as follows:
...
B. retrieve the Sun node of the context node
This XPath queries All sub-elements Child element:
/Child: Customer/child: Order
In this query, child is the axis, and Customer and Order are Node tests (if Customer and Order are Node, the test for these nodes is TRUE, because Node is the primary node of the child axis ). For each matching Will match Add the node to the result. Only return in the result set .
Child is the default axis. Therefore, you can specify this query:
/Customer/Order
Test the XPath query on the ING architecture
Create the following template (MyTemplate. xml) and save it in the directory associated with the template virtual name.
/Customer/Order
In the XPath query, specify the axis (