sam wrote:
I need to know a way for knowing tag position in a xml like this:
<AAA>
<BBB>
<CCC>
<DDD_1/>
<DDD_2/>
<DDD_3/>
</CCC>
<BBB/>
</AAA>
I need to get that AAA = 1, BBB=2,CCC=3,
DDD_1=4, DDD_2=4,DDD_3=4
count($n/ancestor::node()) where $n is your node. So with a stylesheet
you could do:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="//*"/>
</xsl:template>
<xsl:template match="*">
<xsl:value-of select="concat(name(), ' = ',
count(./ancestor::node()))"/>
<xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/