I’m stuck to getting data from this xml:
<?xml version="1.0" encoding="UTF-8"?>
<document>
<AAA>Header</AAA>
<BBB>
<CCC>
<DDD>
<EEE>123123</EEE>
<FFF>
<GGG>
<HHH>Body</HHH>
<III>1</III>
</GGG>
<GGG>
<HHH>Body</HHH>
<III>3</III>
</GGG>
</FFF>
</DDD>
</CCC>
<CCC>
<DDD>
<EEE>234234</EEE>
<FFF>
<GGG>
<HHH>Body</HHH>
<III>2</III>
</GGG>
<GGG>
<HHH>Body</HHH>
<III>4</III>
</GGG>
<GGG>
<HHH>Body</HHH>
<III>6</III>
</GGG>
</FFF>
</DDD>
</CCC>
<CCC>
<DDD>
<EEE>345345</EEE>
<FFF>
<GGG>
<HHH>Body</HHH>
<III>7</III>
</GGG>
</FFF>
</DDD>
</CCC>
</BBB>
</document>
Needed result should be:
Header;
Body;1;123123
Body;3;123123
Body;2;234234
Body;4;234234
Body;6;234234
Body;7;345345
My xslt looks:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="text" encoding="Windows-1257" indent="yes"/>
<xsl:template match="/">
<!--Start Header--><xsl:value-of select="document/AAA"/><xsl:text>;</xsl:text>
<!--End Header--><xsl:text>
</xsl:text>
<xsl:for-each select="document/BBB/CCC/DDD/FFF/GGG">
<!--Start Body--><xsl:value-of select="HHH"/><xsl:text>;</xsl:text>
<xsl:value-of select="III"/><xsl:text>;</xsl:text>
<xsl:value-of select="../EEE"/><--This doesn't work-->
<!--End Body--><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
now I have problem to get value from EEE tag. Please help to solve it because I have no idea how to do it.
From your
for-eachstatement the current context that you are working at isdocument/BBB/CCC/DDD/FFF/GGG.The full path of the
EEEstatement isdocument/BBB/CCC/DDD/EEE.Therefore you need to come back two levels to reach the
EEEnode from theGGGnode: