473,322 Members | 1,718 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,322 software developers and data experts.

Anybody experience XPath anxiety?

I was wondering if anybody gets similar results when attempting to query an
XML Doc with an XPath query or if this is expected behavior or if I'm using
something incorrectly.

<xml ...>
<LoginInfo>
<user>
<username>test</username>
<password>test</password>
</user>
<user>
<username>why won't </username>
<password>this work</password>
</user>
</LoginInfo>
'vb.net code below
dim x as new xmldocument()
x.load("c:\filepath.xml")
dim y as xmlnodelist
y=x.selectnodes("/user[username='test']")

'When I examine the value of y, it holds something like "testtestwhy
won'tthiswork"
'I thought my query was bad, so I ran it in an .htm with IE and got the
result set I was looking for, namely

<user>
<username>test</username>
<password>test</username>
</user>

any ideas on why .net returns a string like that?
Nov 12 '05 #1
3 1433
Try //user[username='test'] or /LoginInfo/user[username='test']

Wole
"Clamps" <Cl****@RobotMafia.Futurama.com> wrote in message news:Ok*************@TK2MSFTNGP09.phx.gbl...
I was wondering if anybody gets similar results when attempting to query an XML Doc with an XPath query or if this is expected behavior or if I'm using something incorrectly.

<xml ...>
<LoginInfo>
<user>
<username>test</username>
<password>test</password>
</user>
<user>
<username>why won't </username>
<password>this work</password>
</user>
</LoginInfo>
'vb.net code below
dim x as new xmldocument()
x.load("c:\filepath.xml")
dim y as xmlnodelist
y=x.selectnodes("/user[username='test']")

'When I examine the value of y, it holds something like "testtestwhy won'tthiswork"
'I thought my query was bad, so I ran it in an .htm with IE and got the result set I was looking for, namely

<user>
<username>test</username>
<password>test</username>
</user>

any ideas on why .net returns a string like that?
Nov 12 '05 #2
Wole, I got the same result.
So I did a bit more tooling around and found that when I use
//user[username='why won't'] that I get the same result set. I thought my
query was good. Did you compile my snippet?
"Wole Ogunremi" <wo*************@SPAMntlworld.com> wrote in message
news:jL****************@newsfe6-gui.ntli.net...
Try //user[username='test'] or /LoginInfo/user[username='test']

Wole
"Clamps" <Cl****@RobotMafia.Futurama.com> wrote in message
news:Ok*************@TK2MSFTNGP09.phx.gbl...
I was wondering if anybody gets similar results when attempting to query
an XML Doc with an XPath query or if this is expected behavior or if I'm
using something incorrectly.

<xml ...>
<LoginInfo>
<user>
<username>test</username>
<password>test</password>
</user>
<user>
<username>why won't </username>
<password>this work</password>
</user>
</LoginInfo>
'vb.net code below
dim x as new xmldocument()
x.load("c:\filepath.xml")
dim y as xmlnodelist
y=x.selectnodes("/user[username='test']")

'When I examine the value of y, it holds something like "testtestwhy
won'tthiswork"
'I thought my query was bad, so I ran it in an .htm with IE and got the
result set I was looking for, namely

<user>
<username>test</username>
<password>test</username>
</user>

any ideas on why .net returns a string like that?
Nov 12 '05 #3
Clamps

I did not compile your snippet but ran it thru Visual XPath Analyzer which is a .NET tool.
http://www.topxml.com/code/default.a...xpath&sw=categ

//user[username="why won't"] returns the expected nodeset...

Good luck
Wole

"Clamps" <Cl****@RobotMafia.Futurama.com> wrote in message news:ud**************@TK2MSFTNGP11.phx.gbl...
Wole, I got the same result.
So I did a bit more tooling around and found that when I use //user[username='why won't'] that I get the same result set. I thought my query was good. Did you compile my snippet?
"Wole Ogunremi" <wo*************@SPAMntlworld.com> wrote in message news:jL****************@newsfe6-gui.ntli.net...
Try //user[username='test'] or /LoginInfo/user[username='test']

Wole
"Clamps" <Cl****@RobotMafia.Futurama.com> wrote in message news:Ok*************@TK2MSFTNGP09.phx.gbl...
I was wondering if anybody gets similar results when attempting to query an XML Doc with an XPath query or if this is expected behavior or if I'm using something incorrectly.

<xml ...>
<LoginInfo>
<user>
<username>test</username>
<password>test</password>
</user>
<user>
<username>why won't </username>
<password>this work</password>
</user>
</LoginInfo>
'vb.net code below
dim x as new xmldocument()
x.load("c:\filepath.xml")
dim y as xmlnodelist
y=x.selectnodes("/user[username='test']")

'When I examine the value of y, it holds something like "testtestwhy won'tthiswork"
'I thought my query was bad, so I ran it in an .htm with IE and got the result set I was looking for, namely

<user>
<username>test</username>
<password>test</username>
</user>

any ideas on why .net returns a string like that?
Nov 12 '05 #4

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
6
by: Scott Simpson | last post by:
What is a good tool for running XPath queries on Linux? I have the O'Reilly XPath book and I'm using XPath Visualizer on Windows and that seems to work fine, but I'm looking for something on Linux....
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
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"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.