Forum Moderators: open
For example:
<tag1 ID='whatever'><tag2 arg='a'><tag3> Text here <tag4>More text</tag4></tag3></tag2></tag1>
would become:
<tag1 ID='whatever'>
.<tag2 arg='a'>
..<tag3>
...Text here
...<tag4>More text</tag4>
..</tag3>
.</tag2>
</tag1>
(replace the dots by tabs or spaces)
the software you are looking for probably already exists in your browser.
when loading xml-data into a modern browser it will apply an internal stylesheet for display which nearly does what you want (it adds a '-' or '+' to some entries though).
alternatively you can supply your own stylesheet specifying
<xsl:output indent="yes"/>
and using an indentity-transform similar to:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" /><xsl:template match="/">
<xsl:apply-templates/>
</xsl:template><xsl:template match="*¦@*¦node()">
<xsl:copy>
<xsl:apply-templates select="*¦@*¦node()"/>
</xsl:copy>
</xsl:template></xsl:stylesheet>
in this untested example you still will have to change unwanted linefeeds to spaces. you could use normalize-space() here.