468,301 Members | 1,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

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 1308
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by bdinmstig | last post: by
4 posts views Thread by Son KwonNam | last post: by
6 posts views Thread by Scott Simpson | last post: by
5 posts views Thread by laks | last post: by
9 posts views Thread by David Thielen | last post: by
5 posts views Thread by Gnic | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.