Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove XML declaration using xslt

Tags:

xslt

I have below XML and want to remove the xml declaration from the payload using XSLT.Please suggest. Input

<?xml version="1.0" encoding="utf-8"?> 
<1>
<a>test1</a>
<a>test2</a>
</1> 

Output:

<1>
<a>test1</a>
<a>test2</a>
</1> 
like image 208
user63827 Avatar asked Oct 19 '25 03:10

user63827


1 Answers

Use the xsl:output tag

<xsl:output method="xml" omit-xml-declaration="yes" />

With the identity transform

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" omit-xml-declaration="yes" />
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
like image 63
Archimedes Trajano Avatar answered Oct 22 '25 04:10

Archimedes Trajano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!