cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to Delete empty fields/Tags from input xml?

GBekkanti
New Contributor III

Hi Team,

I have a requirement to delete the fields which are empty. Can you please help me on this.

Thanks and Regards,
Gopi Bekkanti.

1 REPLY 1

jovan_j
New Contributor III

Hi GBekkanti,

You can use the following XSLT lines to remove all empty elements from XML:
<xsl:stylesheet version=โ€œ1.0โ€ xmlns:xsl=โ€œXSLT Namespaceโ€>
<xsl:output omit-xml-declaration=โ€œyesโ€ indent=โ€œyesโ€/>
<xsl:strip-space elements=โ€œ"/>
<xsl:template match="node()|@
โ€>
<xsl:copy>
<xsl:apply-templates select=โ€œnode()|@โ€œ/>
</xsl:copy>
</xsl:template>
<xsl:template match=โ€
[not(@||comment()|processing-instruction()) and normalize-space()=โ€˜โ€™]โ€/>
</xsl:stylesheet>

  1. Make file with .xslt extension, and copy paste the lines provided above.
  2. Drag XSLT snap and upload the .xslt file.

imageremoveEmptyElements.txt (458 Bytes)