954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XPATH extract

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:

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
on the XML

thanks in advance!

mole116
Newbie Poster
3 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

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.

mrame
Light Poster
37 posts since Feb 2011
Reputation Points: 10
Solved Threads: 4
 

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

mole116
Newbie Poster
3 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Try the below:

<xsl:template match="Name">

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

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

</xsl:template>
mrame
Light Poster
37 posts since Feb 2011
Reputation Points: 10
Solved Threads: 4
 

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?

mole116
Newbie Poster
3 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Try this xpath expression

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

is the element

mrame
Light Poster
37 posts since Feb 2011
Reputation Points: 10
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You