Solved

XML SelectSingleNode

Posted on 2009-04-15
3
673 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

744 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

17 Experts available now in Live!

Get 1:1 Help Now