Solved

XML Namespaces and SelectNodes

Posted on 2004-09-09
4
661 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
Javert93 earned 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

733 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