How to remove namespace attribute from XML root element using XSLT?

There are occasions when we need to remove the namespace attribute from the XML root element before sending it to the receiving application. This can be done using XSL transform as shown below. If you are already doing an XSL transform just include the following code in that XSLT.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="UTF-8" />
	<xsl:template match="*">
		<xsl:element name="{local-name()}">
			<xsl:apply-templates select="@* | node()"/>
		</xsl:element>
	</xsl:template>
</xsl:stylesheet>

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment