Maziar Aflatoun wrote:
I have a string variable that contains XML data with many different
namespaces. I like to remove all the namespaces from my XML (clean the XML).
What's the quickest way to do this?
Ex.
<report xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" > change to
<report>
That is easy as the namespace declared is not used.
What do you want to get from
<pf:report xmlns:pf="http://example.com/2005/ns1" />
?
As for removing namespaces XSLT is certainly a tool that can do it so
within .NET you could use XslTransform to transform the XML with an XSLT
stylesheet that removes namespaces e.g. uses
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()" />
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:template>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/