Solved

XSL: retrieve value inside a node with conditions

Posted on 2014-02-26
4
204 Views
Last Modified: 2014-02-27
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
Comment
Question by:badtz7229
  • 3
4 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 39891155
<xsl:value-of select="/root/RQ/Other/Add[id = $id]/MC[Type='A' or Type='V']/Number "/>
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39891160
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
 

Author Closing Comment

by:badtz7229
ID: 39891719
thx. that worked.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39891824
welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
push text up below h2 tag 1 36
XML to Excel using XSL - formatting 3 26
Alignment is not working correctly. 8 32
Shredding xml into an oracle 11g Database 2 27
Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now