Solved

Select node value by variable

Posted on 2004-10-06
2
381 Views
Last Modified: 2010-05-18
I have this code:

<xsl:template name="cad">
      <xsl:param name="CadType"> RCAD </xsl:param>
      <xsl:variable name="FieldName" select="concat('Org-', $CadType)"/>
      <xsl:value-of select="$FieldName">
                <xsl:value-of select="Org-RCAD">
</xsl:template>

<xsl:value-of select="$FieldName"> will give me "Org-RCAD"
whereas <xsl:value-of select="Org-RCAD"> will give me the value in the node <Org-RCAD>value</Org-RCAD>, which is what I want.

How can I pass in a node name through a variable and get the node's value out?  Thanks.
0
Comment
Question by:wunyu
2 Comments
 
LVL 19

Accepted Solution

by:
ramazanyich earned 100 total points
ID: 12241120
use
<xsl:value-of select="child::*[name()=$FieldName]"/>
instead of
<xsl:value-of select="Org-RCAD">
0
 

Author Comment

by:wunyu
ID: 12242043
Thanks for the quick solution.  It worked!!!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
illegal characters in XML using UTF-8 8 37
Error opening .xml with Excel 2013 4 26
Convert XSD to XML 3 102
[PHP] Hash a XML file/string 3 67
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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