The examples below make queries against the document XMLExtractionExamples1.xml: AM represents an attribute mark, VM a value mark and SVM a subvalue mark.
<server> <services> <service name="Devices" port="%1%"/> </services> </server>
5300
Extracts the value of the port
attribute from the <service>
node with the name
attribute "Devices".
<server> <services> <service port="5001" name="%1%" /> </services> </server>
Time
Extracts the value of the name
attribute from the <service>
node with the port
attribute "5001". Note that the fixed,
defining attribute (port="5001"
) appears before the attribute
containing the extraction sequence (name="%1%"
).
<server> <services> <service name="Time" port="%1%"/> </services> </server>
5001VM5002
Extracts the value of the port
attribute from the <service>
node with the name
attribute "Time". Because the query node
has no sibling nodes, the query can match multiple document nodes at the same
level. The result therefore includes values from all matching document nodes,
separated by value marks.
<server> <services> <service name="Time" port="%1%"/> <service name="MultiGateWay" port="%2%"/> </services> </server>
5001am
5100
Extracts the values of the port
attributes from the <service>
nodes with the names
attribute "Time" and "MultiGateWay".
The "Time" value is placed in attribute 1 and "MultiGateWay" in
attribute 2. Note that the <service>
nodes in the query are in the same
order as in the XML document. If the "Time" node had been placed after "MultiGateWay",
only the latter value would have matched because there are no "Time" nodes
following the first "MultiGateWay" node (see
Sequential Mode).
<server> <services __nis_cont="P"> <service name="Time" port="%1%"/> <service name="MultiGateWay" port="%2%"/> </services> </server>
5001VM5002aM 5100VM6100
This example is similar to Example 4, but the
<services>
node includes a __nis_cont
attribute to change to
parallel processing mode. As a
result, values from all matching nodes are returned, because the order in which
they appear in the XML document is no longer significant.
<server> <services> <service name="SingleGateWay" port="%1%" realport="%2%" destport="%3%"/> </services> </server>
5101VM5102VM5103AM 101VM102VM103aM 23
Extracts the values of the port,
realport
and
destport
attributes from the <service>
node with the name
attribute "SingleGateWay". Because the
query node has no sibling nodes, the query can match multiple document nodes at
the same level. The attributes in the result therefore include values from all
matching document nodes, separated by value marks (the last attribute contains
only a single multivalue because only the first of the matching nodes contains a
destport
attribute).
<server> <services __nis_cont="T"> <service name="SingleGateWay" port="%1%" realport="%2%" destport="%3%"/> </services> </server>
5101VM5102VM5103aM 101VM102VM103aM 23VMVM
This example is similar to Example 6, but the
<services>
node includes a __nis_cont
attribute to change to
tabulation mode. As a result,
the final attribute contains blank multivalues, corresponding to the missing
destport
attributes.
<server> <comment>%1%</comment> </server>
Simple comment
Extracts the value of the <comment>
node.
<server> <description>%1%</description> </server>
Line 1 of description Line 2 of description
Extracts the value of the <description>
node. In the result,
leading and trailing white space is discarded and the lines are separated by new
line characters.
<server> <terminal-ports> %1% </terminal-ports> </server>
<entry device="COM2" service="TerminalPort" port="5602" realport="202"/> <entry device="COM3" service="TerminalPort" port="5603" realport="203"/>
Extracts all the child nodes from the <terminal-ports>
node. In the
result, leading and trailing white space is discarded and the lines are
separated by new line characters.