hi,

i have a question in XPATH.
i am reading from XML file and i would like to know how can i extract a name from this line:
<Name><![CDATAEdi></Name>
lets say i want to get Dani?

my c# query is like this:
strExpression = "A/B/C/D";

and i also would like that it won't skip lines like this <Name><![CDATADani]></Name>
on the XML

thanks in advance!

I think you are talking about CDATA sections. With the below input XML

<Name><![CDATA[Dani]]></Name>

and XSLT code

<xsl:template match="Name">

<xsl:value-of select="."/>

</xsl:template>

I got "Dani" as the output.

sorry but i forgot to write the strexpresion right:
strExpression = "A/B/C/D[.../name="dani"]";

and i still dont understand how in xpath can i extract dani from cdata like this because its not working for me
<Name><![CDATAEdi/beni/dani></Name>

Try the below:

<xsl:template match="Name">

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

<xsl:value-of select="substring-after(substring-after($name,'/'),'/')"/>

</xsl:template>

Try the below:

<xsl:template match="Name">

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

<xsl:value-of select="substring-after(substring-after($name,'/'),'/')"/>

</xsl:template>

10x a lot for the help,but i already using XPATH on all of my code...
anyway i can do it on XPATH?

Try this xpath expression

substring-after(substring-after(name,'/'),'/')

<name> is the element

This article has been dead for over six months. Start a new discussion instead.