Solved

XML SelectSingleNode

Posted on 2009-04-15
3
676 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 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