Hi,
Thanks for the quick reply; I have modified your code slightly as follows..
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text()"/>
<xsl:template match="*">
<xsl:for-each select="//node()">
name=<xsl:value-of select="name()"/>
depth=<xsl:value-of select="count(ancestor::*)"/>
attributes=(<xsl:apply-templates select="@*"/>)
</xsl:for-each>
</xsl:template>
<xsl:template match="@*">
name=<xsl:value-of select="name()"/>
value=<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
The source XML I use is this..
Code:
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</catalog>
And the output I get from the XSL is this..
Code:
name=catalog
depth=0
attributes=()
name=
depth=1
attributes=()
name=book
depth=1
attributes=(
name=id
value=bk101)
In the above output, I miss value of tags themselves, e.g. publish_date
It would be great if you could help me with this..
Thanks & cheers