xslt - How to get XML element based on given value -


i want retrieve xml element node based on given string value. element node can described @ levels in nested xml, there no specific structure xml has. how in xslt transformation?

i use key:

<xsl:key name="k1" match="*[not(*)]" use="."/> 

then can use e.g.

<xsl:param name="string-value" select="'foo'"/> 

and

<xsl:variable name="elements" select="key('k1', $string-value)"/> 

if there can several elements same contents , interested in first use

<xsl:variable name="element" select="key('k1', $string-value)[1]"/> 

that assumes want find elements no child elements string value matches variable, other approaches matching on name of element of course possible: <xsl:key name="k1" match="*" use="local-name()"/>.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -