XSL: retrieve value inside a node with conditions

badtz7229
badtz7229 used Ask the Experts™
on
How do i retrieve value of the <Number> element when id is a given value

<Add>
      <id>T1</id>
      <MC>
            <Type>A</Type>
            <Number>44444</Number>
      </MC>
</Add>
                  
I'm trying to do something like
<xsl:value-of select="/root/RQ/Other/Add[MC[Type='A' or Type='V']]/id = $id/ Number "/>

but this is failing. i know i'm missing a bracket somewhere. can someone please assist?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Information Architect
Top Expert 2006
Commented:
<xsl:value-of select="/root/RQ/Other/Add[id = $id]/MC[Type='A' or Type='V']/Number "/>
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
or make a key
<xsl:key name="add" match="Add" use="id"/>
at the start of your XSLT

and use <xsl:value-of select="key('add', $id)/MC[Type='A' or Type='V']/Number"/>

anywhere in the XSLT (where you have access to $id of course)

Author

Commented:
thx. that worked.
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
welcome

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial