0

Let's say I have a variable in an XSL sheet like this:

<xsl:variable name="myID" select="."/>

And assume that 'myID' holds an existing attribute name of an XML tag. I want to be able to access the value of that attribute in another file with the same attribute name.

I've tried this:

<xsl:value-of select="@$myID"/>

But that doesn't appear to work. What is the proper way to access the value of an attribute with a variable name?

1

1 Answer 1

2

XPath: "Of all the attributes, pick the one with the name equal to $myID"

<xsl:value-of select="@*[name() = $myID]"/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.