August 2000
Beginner
456 pages
9h 24m
English
As you've seen many times s in your study of XML, the child nodes of XML are automatically numbered or indexed starting at 0. The index() method allows for the selection of a single node by extracting the node with a specific index.
Go back to the HTML file and modify the GrabNodes() function to match Listing 17.2.
1: function GrabNodes()
2: {
3: var NodeData=DataSource1.selectNodes("//Book/*[index()=2]");
4: moveNode=NodeData.nextNode();
5: while(moveNode!=null)
6: {
7: document.write(moveNode.text+"<BR>");
8: moveNode=NodeData.nextNode ();
9: }
10: }
|
When you view the file in IE, the output is the contents of the <Publisher> nodes. Since you're using the selectNodes() ...
Read now
Unlock full access