Reputation: 49
I am trying to xslt nodes with name=SomeName2
and getting their childnode text as output. I don't know where they are in xml file and their position is always different in different xml files.
Is there an option to research an xml file for node names, not for a node namespaces?
Here my XML File:
<con1:node>
<con2:node name="SomeName">
<con2:path>'Text'</con2:path>
</con2:node>
<con2:node name="SomeName2">
<con2:path>'Text'</con2:path>
</con2:node>
<con2:node name="SomeName3">
<con2:path>'Text'</con2:path>
</con2:node>
<con1:node>
Upvotes: 0
Views: 69
Reputation: 3435
you can use:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output indent="yes" method="text"/>
<xsl:template match="/">
<xsl:value-of select="//@name[normalize-space(.) = 'SomeName2']/parent::*"/>
</xsl:template>
</xsl:stylesheet>
Upvotes: 1