pradeep
pradeep

Reputation: 295

get node value based on another node value from list of xml nodes using xslt

this is the input xml,

<student>
    <roll-no>5</roll-no>
    <name>patrick</name>
</student>
<student>
    <roll-no>6</roll-no>
    <name>steve</name>
</student>
<student>
    <roll-no>7</roll-no>
    <name>liz</name>
</student>
<student>
    <roll-no>8</roll-no>
    <name>smith</name>
</student>

need to get the name of the student if the roll-no is 7

so the output should be 'liz'

please help me.

Upvotes: 1

Views: 271

Answers (1)

Rupesh_Kr
Rupesh_Kr

Reputation: 3435

Try this

<xsl:value-of select="//student[roll-no eq '7']/name"/>

Upvotes: 1

Related Questions