Solved

XML Namespaces and SelectNodes

Posted on 2004-09-09
4
651 Views
Last Modified: 2013-11-19
I have an XML file with the line:

 <REQUEST_GROUP MISMOVersionID="2.3.1" _ID="XSLT120" xmlns="http://www.MISMO.org/schema/Envelope_2_3_1">

When I try to do a SelectSingleNode method to that node, i get a null refrence

When I modify that line to

 <REQUEST_GROUP MISMOVersionID="2.3.1" _ID="XSLT120">

it selects just fine.

What does SelectSingleNode have to do with namespacing?
0
Comment
Question by:Siberwulf
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
Javert93 earned 500 total points
Comment Utility
XML namespaces allow you to logically seperate nodes with the same name into different "areas" or "namespaces." When you don't specify a namespace, the node is placed in a global namespace, which was where SelectSingleNode looks if you don't provide an XmlNamespaceManager for the second parameter. Since you were defining the node to be in the http://www.MISMO.org/schema/Envelope_2_3_1 namespace (which removed it from the default namespace).
0
 

Author Comment

by:Siberwulf
Comment Utility
Ok, I see how that works.

Now, it is having me look in the namespace each time i try to acess a node inside.  

I end up wiht something like this:

"//mismo:REQUEST_GROUP/mismo:REQUEST/mismo:REQUEST_DATA"


Is there any way to not have it need those extra namespace tags?
0
 
LVL 4

Expert Comment

by:Javert93
Comment Utility
Not unless you don't define a namespace for the nodes. Otherwise, the namespace is required.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 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

10 Experts available now in Live!

Get 1:1 Help Now