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

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 2341
* 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
10
by: Michael C# | last post by:
OK, here's the deal. I have a small XML file that represents a small database table. I load it into a System.XML.XMLDocument. So far so good. I run an XPath query against it to retrieve all the...
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...
3
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer>...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
3
by: ziggyware | last post by:
Hi All, I have updated my XPath Generator software: XPath Studio .NET. ( http://www.ziggyware.com/downloads.php?cat_id=2 ) Easily select nodes from an xml file to generate XPath statements ...
5
by: rcronk | last post by:
I'm new to C#/.NET. I am writing some C#/.NET (2.0) classes that will allow someone to get and set values in an XML file using an XPath to point to the location of that data. It's more complicated...
2
by: arunairs | last post by:
Hi, Is there a way of validating and XPath? In this case , I am accepting an XPath from the user and I need to validate the XPath syntax. Is there a regular expression available that anyone can...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.