Solved

Select node value by variable

Posted on 2004-10-06
2
385 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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Delete from XML 10 47
How to read XML file attributes... 17 70
XML & .net 5 48
Append data to an XML file 3 14
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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