Groups | Blog | Home
all groups > dotnet xml > august 2003 >

dotnet xml : XPath woes [vb.net]


ArmsTom
8/19/2003 7:37:22 PM
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.


ArmsTom
8/20/2003 4:15:50 AM
Thanks for pointing that out.

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

[quoted text, click to view]
Bjoern Hoehrmann
8/20/2003 5:25:51 AM
* ArmsTom wrote in microsoft.public.dotnet.xml:
[quoted text, click to view]

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
Oleg Tkachenko
8/20/2003 11:15:11 AM
[quoted text, click to view]
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
AddThis Social Bookmark Button