Solved

XML SelectSingleNode

Posted on 2009-04-15
3
674 Views
Last Modified: 2013-11-18
I am trying to extract all child nodes in an XML document with a certain name, using the SOAP toolkit.
At the moment I cannot extract anything further down than the root, I need to find nodes in the body of the XML.
My XML document uses a bespoke namespace, so I am using this syntax:
Set objNode = oRoot.selectSingleNode("testNS:Results")
Where Results is the root node. This works and I get a node back.

But I am looking 5 levels down into the XML for what I really want.
When I try this (retrieve a node below the root ):

Set objNode = oRoot.selectSingleNode("testNS:Results/Level2")

I get nothing.

What am I doing wrong?
0
Comment
Question by:BrianGilbert
3 Comments
 
LVL 9

Accepted Solution

by:
dan_neal earned 25 total points
ID: 24147079
If you want to return all nodes of with a certain name you should use SelectNodes(xpath).  SelectSingleNode give you just the one node and its children instead of all nodes of that name and their children.
0
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 25 total points
ID: 24147618
dan_neal has a point about using selectNodes to get the entire set,
but there is more, you need to change the XPath too,
now your XPath only looks at the top level
In order for XPath to dig deeper in the tree, you will need a "//" denoting that you need that patteren anywhere in the tree

Set objNodes = oRoot.selectNodes("//Level2")
make sure you have the namespace right
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to dynamically set the form action using jQuery.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now