• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

XSL: retrieve value inside a node with conditions

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?
0
badtz7229
Asked:
badtz7229
  • 3
1 Solution
 
Geert BormansCommented:
<xsl:value-of select="/root/RQ/Other/Add[id = $id]/MC[Type='A' or Type='V']/Number "/>
0
 
Geert BormansCommented:
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)
0
 
badtz7229Author Commented:
thx. that worked.
0
 
Geert BormansCommented:
welcome
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now