Solved

XSL: retrieve value inside a node with conditions

Posted on 2014-02-26
4
205 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Download a website to hdd 2 65
Custom Form Design to Match this example 1 22
configure dependency in POM for new database 3 25
SQL Result Set to XML 4 36
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…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

813 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

15 Experts available now in Live!

Get 1:1 Help Now