Retrieving value of attributes in XML using XSLT



To extend the solution provided here, the aim is to retrieving value of attributes in addition their names.


For this doc,



<a>
<apple color="red"/>
<apple color="green"/>
<banana color="yellow"/>
<sugar taste="sweet"/>
<cat size="small"/>
</a>


The code, in the above post, provides this result:



For tags: apple 2, banana 1, sugar 1, cat 1
For attributes: color 3, taste 1, size 1


Now, the desired result is :



For tags: apple 2, banana 1, sugar 1, cat 1
For attributes: color(red) 1, color(green) 1, color(yellow) 1, taste(sweet) 1, size (small) 1


Thanks a lot.


No comments:

Post a Comment