<Dept>
<Employee> John Smith </Employee>
<Employee> Jane Doe </Employee>
</Dept>
Name | Value | XPath | NodeID | NType |
Employee | John Smith | /Dept/Employee[1] | 18276465 | 1 |
Employee | Jane Doe | /Dept/Employee[2] | 28376473 | 1 |
NType | Description |
1 | Element |
2 | Attribute |
3 | Text |
4 | CDATA |
5 | Entity reference |
6 | Entity |
7 | Processing instruction |
8 | Comment |
9 | Root XML document |
; Retrieve all the elements in the tree.
entire_tree = XmlEvaluate(doc_id)
; get all the 'value' attributes.
att_table = XmlEvaluate(doc_id,'//@value')
; Build a DOM tree.
doc_id = XmlParse('chart.xml', /File)
; Changes the start location for XPATH query.
context_id = XmlSetContext(doc_id, Path='/Chart/CharTitle')
; Use the relative path to the Attribute node.
subtree = XmlEvaluate(doc_id, 'Attribute', $
Context_id=context_id)
doc_id = XmlParse('chart.xml', /File)
table = XmlEvaluate(doc_id, '//*')
FOR i=0L, N_ELEMENTS(table)-1 DO PRINT,table(i)
; Print all of the node information for an XML file.
; The following is the result of this query:
; { Chart /Chart 26395416 1}
; { ChartTitle /Chart/ChartTitle 26427072 1}
; { Attribute Line Chart /Chart/ChartTitle/Attribute[1] 26480152
; 1}
; { Attribute /Chart/ChartTitle/Attribute[2] 26480464 1}
; { Attribute /Chart/ChartTitle/Attribute[3] 26442656 1}
; { AxisXY /Chart/AxisXY 26443032 1}
; { Data /Chart/AxisXY/Data[1] 26443128 1}
; { Attribute /Chart/AxisXY/Data[1]/Attribute[1]
; 26470416 1}
; { Attribute /Chart/AxisXY/Data[1]/Attribute[2]
; 26470776 1}
; { Attribute /Chart/AxisXY/Data[1]/Attribute[3]
; 26471176 1}
; { Attribute /Chart/AxisXY/Data[1]/Attribute[4]
; 26480736 1}
; { Attribute /Chart/AxisXY/Data[1]/Attribute[5]
; 26481136 1}
; { Data /Chart/AxisXY/Data[2] 26481512 1}
; { Attribute /Chart/AxisXY/Data[2]/Attribute[1]
; 26481784 1}
; { Attribute /Chart/AxisXY/Data[2]/Attribute[2]
; 26482168 1}
; { Attribute /Chart/AxisXY/Data[2]/Attribute[3]
; 26482552 1}
; { Attribute /Chart/AxisXY/Data[2]/Attribute[4]
; 26482944 1}
; Print the attribute value for the first node named 'Data'.
attribute_node = XmlEvaluate(doc_id, '/Chart/AxisXY/Data[1]/@*')
PRINT, attribute_node.value
; PV-WAVE prints:
; {6,5,7,1}
; Print the attribute value for the second node named 'Data'.
attribute_node = XmlEvaluate(doc_id, '/Chart/AxisXY/Data[2]/@*')
PRINT, attribute_node.value
; PV-WAVE prints:
; {1,3,6,8}