ignore/remove Namespace URI
I have a xml file with NameSpace on the root node let say xmlns="http://www.mysite.com/"
i.e.
<?xml version="1.0" ?>
<customers xmlns="http://www.mysite.com/">
<customer job > ....
I am loading this into xmldocument
whaty I want's is to ignore or remove NameSpaceURI from the Xmldocument
It is making some problem in the parsing of the docuement
What Can I do
I am working on .netframework 1.1
[476 byte] By [
Kamii47] at [2007-12-27]
It does not make much sense usually to try to remove/strip namespaces from an XML document. And the "problem in parsing" a document with namespaces can usually easily be solved as they are usually caused by a lack of understanding of how XPath works or how the DOM works to find or create elements/attributes in a namespace.
So what problems do you have? Let's try to address those problems by properly using the XPath or DOM APIs, not by trying to remove namespaces.
Let Say following is my XML
<?xml version="1.0" ?>
<customers xmlns="http://www.mysite.com/">
<customer>
<customerid >12345</customerid>
<description>dfhsdfkhsdfkjsdkjfsdkjf</description>
<location>
<region-id>usa.fl.Pensacola/Panama City</region-id>
<city>Pensacola - 32504-0000</city>
<state>FL</state>
<country>USA</country>
</location>
</customer>
<customer>
<customerid >7891</customerid>
<description>dfhsdfkhsdfkjsdkjfsdkjf</description>
<location>
<region-id>Pacific</region-id>
<city>Newyork</city>
<state>NY</state>
<country>USA</country>
</location>
</customer>
</customers>
how get I read the the description ,city and stateof the customer with particular id let say 12345
For the example given, the namespace just gets in the way - adding the namespace manager, passing it to all the queries, and worst of all, having to stick it in front of every single component in the XPath query. I know the XML purists will bristle at this, but it's easier to just ignore it. Just change how the document is loaded:
XmlDocument d = new XmlDocument();
using (XmlTextReader tr = new XmlTextReader(path))
{
tr.Namespaces = false;
d.Load(tr);
}
This loads your XML document as if it had no namespace.
/Frank