Home All Groups Group Topic Archive Search About

remove xml file namespace attribute

Author
9 Nov 2006 3:38 PM
martin1
Hi, All,

I want to remove xml namespace attribute
(xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance") in the following file

<AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Table1>
<Data1>  10 </Data1>
<Data2>  20 </Data2>
<Data3>  40 </Data3>
<Table1>
</AutoData>

So finally the file without namespace is like this:

<AutoData >
<Table1>
<Data1>  10 </Data1>
<Data2>  20 </Data2>
<Data3>  40 </Data3>
<Table1>
</AutoData>

Any advice?

Thanks
Martin

Author
9 Nov 2006 4:49 PM
Martin Honnen
martin1 wrote:

> I want to remove xml namespace attribute
> (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance") in the following file
>
> <AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <Table1>
> <Data1>  10 </Data1>
> <Data2>  20 </Data2>
> <Data3>  40 </Data3>
> <Table1>
   ^^^^^^^^

Note that the sample markup you post is not even well-formed XML. You
need a </Table1> there.


As for removing that attribute assuming the XML is well-formed and has
been loaded into an XmlDocument instance as shown earlier you can do e.g.
   Xml_Document.DocumentElement.RemoveAttribute("xsi",
"http://www.w3.org/2000/xmlns/")

--

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/