Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

XML Namespaces and SelectNodes

Posted on 2004-09-09
4
Medium Priority
?
680 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 2000 total points
ID: 12021851
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
ID: 12021966
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
ID: 12022015
Not unless you don't define a namespace for the nodes. Otherwise, the namespace is required.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

916 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