xmltools
xmltools copied to clipboard
Add XML Sort
trafficstars
Please add "XML Sort" funcionality. It's very useful to compare two XML's.
Something like this tool: https://archive.codeplex.com/?p=xmlsorter
Hi,
I'll think about adding such a method. I'm just wondering how to handle comments, cdata blocs, etc. Note that currently you can already do the same with a XSL stylesheet. For instance:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="*">
<xsl:element name="{name()}">
<xsl:apply-templates select="@*">
<xsl:sort select="name()"/>
</xsl:apply-templates>
<xsl:apply-templates select="*">
<xsl:sort select="name()"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Best Regards