You are trying to convert elements that are in a namespace,
http://www.kmrsoftware.net/netquest/analysisquery.xsd, to ones that are in no namespace. Personally I'd use XSLT to do this, the following transform should do this:
Code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()">
<xsl:choose>
<xsl:when test="name() != ''">
<xsl:element name="{name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@*">
<xsl:copy />
</xsl:template>
</xsl:stylesheet>
If you want to stick with DOM manipulation then you will need to loop through all the nodes and create a new element each time you find an element based on the local-name() of the old one.
Why do you want to do this anyway? Normally when people ask this it's because they have difficulty retrieving namespaced nodes, perhaps we can help solve that problem instead?
--
Joe (
Microsoft MVP - XML)