Xpath trouble

S

Shawn

Hi,
I'm looping through an XmlNodeList and the second XmlNode in the list
contains this OuterXml:
<element><name>plant</name><value>100</value></element>
Next I have this XPath (inside the loop):
myXmlNode = myXmlNodeLoop.SelectSingleNode("name[plant]")
This returns Nothing. If I try it like this:
myXmlNode = myXmlNodeLoop.SelectSingleNode("name['plant']")
Then an XmlNode is always retuned, but I don't want it to be returned as it
doesn't contain the value (plant) that I'm looking for.
What am I doing wrong here?

Any help is greatly appreciated!!

Shawn
 
H

Hans Kesting

Shawn said:
Hi,
I'm looping through an XmlNodeList and the second XmlNode in the list
contains this OuterXml:
<element><name>plant</name><value>100</value></element>
Next I have this XPath (inside the loop):
myXmlNode = myXmlNodeLoop.SelectSingleNode("name[plant]")
This returns Nothing. If I try it like this:
myXmlNode = myXmlNodeLoop.SelectSingleNode("name['plant']")
Then an XmlNode is always retuned, but I don't want it to be returned
as it doesn't contain the value (plant) that I'm looking for.
What am I doing wrong here?

Any help is greatly appreciated!!

Shawn

try using: SelectSingleNode("name[text() = 'plant']")
 
S

Shawn

It just returnes Nothing..

Shawn

Hans Kesting said:
Shawn said:
Hi,
I'm looping through an XmlNodeList and the second XmlNode in the list
contains this OuterXml:
<element><name>plant</name><value>100</value></element>
Next I have this XPath (inside the loop):
myXmlNode = myXmlNodeLoop.SelectSingleNode("name[plant]")
This returns Nothing. If I try it like this:
myXmlNode = myXmlNodeLoop.SelectSingleNode("name['plant']")
Then an XmlNode is always retuned, but I don't want it to be returned
as it doesn't contain the value (plant) that I'm looking for.
What am I doing wrong here?

Any help is greatly appreciated!!

Shawn

try using: SelectSingleNode("name[text() = 'plant']")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top