469,625 Members | 1,720 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

XPath woes [vb.net]

I've been playing around with xml for a couple days, so I have no idea what
I'm doing yet :). Be gentle.
Ok, here's what I have...

================================
Do while xmlIter_Records.MoveNext

Dim i As Integer = xmlIter_Records.Current.GetAttribute("id", "")

Dim xmlIter_MovieINfo As XPath.XPathNodeIterator =
xmlXPNav.Select("/Records/Record[@id='" & i & "']/MovieInfo/*")

Do while xmlIter_MovieInfo.MoveNext
...
loop

Loop
=================================
The id above will always be something like "001","002",etc

When using the above, I cannot get the children of /MovieInfo, BUT if I
remove [@id='" & i & "'] with [@id='001'] I get the results I want, which
is to say, the "MovieInfo" children.

Why does that happen? I just don't get it :).

Also, maybe someone can tell me a better way to do this:

Currently, I select each <Record>, get the "id" and create another iterator
that I use the xpath expr "/Records/Record[@id='"id"']". Forgive me if you
already figured that out from the above bit of code. Is there anyway that
I can do this, without two iterators? I know there is.

Nov 11 '05 #1
3 2267
* ArmsTom wrote in microsoft.public.dotnet.xml:
Dim i As Integer = xmlIter_Records.Current.GetAttribute("id", "")

Dim xmlIter_MovieINfo As XPath.XPathNodeIterator =
xmlXPNav.Select("/Records/Record[@id='" & i & "']/MovieInfo/*") The id above will always be something like "001","002",etc


But an Integer does not have leading zeros, thus your expressions is
e.g.

...[@id = '1']...

not

...[@id = '001']...

You need to add those leading zeros again or avoid the use of the
Integer data type (i.e., use a string).
Nov 11 '05 #2
Bjoern Hoehrmann wrote:
You need to add those leading zeros again or avoid the use of the
Integer data type (i.e., use a string).

Or use only Interger type, e.g.
xmlXPNav.Select("/Records/Record[@id=" & i & "]/MovieInfo/*")
(note absent apostrophes).
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3
Thanks for pointing that out.

Bjoern Hoehrmann <bj****@hoehrmann.de> wrote in news:3f6ee9ce.811582163
@news.bjoern.hoehrmann.de:

But an Integer does not have leading zeros, thus your expressions is
e.g.

...[@id = '1']...

not

...[@id = '001']...

You need to add those leading zeros again or avoid the use of the
Integer data type (i.e., use a string).


Nov 11 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Michael C# | last post: by
9 posts views Thread by David Thielen | last post: by
1 post views Thread by Sergey Dubinets | last post: by
3 posts views Thread by ziggyware | last post: by
2 posts views Thread by arunairs | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.