I am new in XSLT, and am learning how to store attribute into a variable.
I have a scenario where my input xml file is :
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book title="ABC" id="1">
<infos>
<info key="pages">200</info>
<info key="price">$1.50</info>
</infos>
</book>
<book title="XYZ" id="1">
<infos>
<info key="pages">300</info>
<info key="price">$3.00</info>
</infos>
</book>
</books>
I want to know how to store the title of a book whose pages is 200, i.e. i need the "ABC" to be stored in a variable.
I have searched many places but all I could find is how to store the last attributes value by using this code :
<xsl:variable name="pages" select="/*/info[.='200']/@key"/>
where i can get the $key value as "pages", but i want title's value
Is is possible to get title's value by using similar approach, if yes then where am i going wrong, Thanks in Advance
<xsl:variable name="pages" select="/*/info[.='200']/@key"/>does not contain anything.