473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Xpath trouble

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
Nov 19 '05 #1
2 973
Shawn wrote:
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']")

Nov 19 '05 #2
It just returnes Nothing..

Shawn

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
Shawn wrote:
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']")


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joshua Beall | last post by:
Hi All, I have a task that should be very simple but I'm running into trouble. All I want to do is query a document using XPath, and save the resulting XML in a string. Here's that I am trying...
1
by: P.Hill | last post by:
I'm using jaxen to pull a few things out of DOM tree and having trouble specifying an xPath. /mapping/to/from works fine, but /mapping/to doesn't. I'm sure it is something obvious. I try...
14
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following...
1
by: andy | last post by:
I am using XPath for the Electric XML Parser and having trouble getting simple XPath queries to work. The following query works: document.getElement(new...
3
by: werD | last post by:
Hello I have an xml document that im currently using a forward only .net repeater on and using some xpath queries to display the data The xml is quite simple <?xml version="1.0"...
3
by: Opa | last post by:
Hi, I have and XMLDataSource which I am using in a GridView control and am customizing the grid with <ItemTemplate>. My XML datasource has an element with an attribute called "private". I want...
5
by: tschulken | last post by:
I have a query where i need to look for a value of a lower level xml element based on the value of a parent element existing first. Here is a simple example of the xml <S3Client> <Buttons>...
14
by: Mikhail Teterin | last post by:
Hello! What's would be the syntax for a query, which would allow me to get only the elements with non-empty text-nodes? For example, from: <a><b></b></a> <c/> <d><e>meow</e></d>
3
by: oopsatwork | last post by:
I'm trying to construct an XPath and it is giving me trouble. I have an XML that contains a "Routine". The routine contains "Steps". The steps have different types. Some types of steps have...
5
Plater
by: Plater | last post by:
I'm having a bit of trouble getting XPath expressions to work to select nodes. I am working with the google maps results. A shortened example xml: <?xml version="1.0" encoding="UTF-8" ?> ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.