Click to See Complete Forum and Search --> : XPath navigation with unwanted namespace


CMulligan
October 13th, 2008, 03:12 PM
I'm passed an object from outside code which I serialize to a file with XmlSerializer. I then load the document with XmlDocument, create an XPathNavigator with it, and then use the Select() function to traverse it.

Only problem is within all the top level xml tags is xmlns="http://tempuri.org/". For some reason with these tags included I can't use Select("//foo") and have to use Select("//*[name()="foo"]) which gets obnoxious fast.

I've found solutions online to this problem, but all deal with removing tempuri from the tag. I don't have access to the code that puts tempuri in there. I'm looking for a way to either prevent "xmlns=www.tempuri.org" from being written when the object is being Serialized or find a way I can still use Select("//foo") even with it in there.

CMulligan
October 13th, 2008, 03:41 PM
Nevermind, forget the problem. The "www.tempuri.org" was being added on my side. For some reason Visual Studio's search wasn't finding it.

If there's a way to use the Select("//foo") even with the unwanted namespace though I'm still curious how to do it.