Solved

XSL: retrieve value inside a node with conditions

Posted on 2014-02-26
4
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Content Page 3 52
Wordpress themes CSS? 6 30
HTML question 2 28
How to add extra IF statement to a loop in MS Access VBA 3 27
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

730 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