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
Solved

XML Namespaces and SelectNodes

Posted on 2004-09-09
4
660 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
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.
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

860 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