BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


XML DOM
How to Load a XML From a String with XmlDocument?
How to remove an attribute with XmlDocument and RemoveAll?
How to create a navigator with XmlDocument and CreateNavigator?
Whats the 'push model'?
Hybrid Model Part Two: Choosing between SAX and DOM


 
 

<< XHTMLXmlSerializer >>


By Sonu Kapoor
First Posted 02/20/2005
Times viewed 1262

How to select specific nodes in XmlDocument() when having a namespace ?


Summary How to select specific nodes in XmlDocument() when having a namespace in the XML?

You can not simple use the SelectNodes or SelectSingleNode function to retrieve specific nodes if you have a namespace in your XML file. If you still do, you will get the following error:

System.NullReferenceException: Object reference not set to an instance of an object.

To get rid of that still get the nodes, you will have to use the XmlNameSpaceManager and add the namespace to the XmlDocument object. In this example you will see how you can achieve that. I am using the following XML file for the example. Note the namespace at the beginning of the file.

Output:

VC++

Additional information

Further additional information


Rate this article on a scale of 1 to 10 (0 votes, average 0)

Your vote :  

<< XHTMLXmlSerializer >>





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML