sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Samik Raychaudhuri's Avatar

Simple Xpath Query


Question posted by: Samik Raychaudhuri (Guest) on November 11th, 2005 10:51 PM
Hello,
I am having the following XML file:
-----
<bibRecords xmlns="http://tempuri.org/bibrecords.xsd">
<bibRecord>
<entryID>1</entryID>
<tag>Shioura97</tag>
<entrytype>Conference Proceedings</entrytype>
</bibRecord>
</bibRecord>
------

Dim oNode As Xml.XmlNodeList
oNodes = xmldoc.SelectNodes("/bibRecords/bibRecord[entryID='1']")

The above 2 lines is returning oNodes.count=0, whereas the following line:

oNodes = xmldoc.GetElementsByTagName("bibRecord")

is returning oNodes.count=1 as expected. Seems like I am making some stupid mistake in the Xpath query, or may be missing something. Can somebody point it out?
Thanks and regards,
--
Samik Raychaudhuri
University of Wisconsin, Madison

To email me, replace 'K' with 'e' in the 'From' field.

1 Answer Posted
Samik Raychaudhuri's Avatar
Samik Raychaudhuri November 11th, 2005 10:51 PM
Guest - n/a Posts
#2: Re: Simple Xpath Query

Well, the solution is more stupid :-( I had to remove the xmlns="http://tempuri.org/bibrecords.xsd" part from first line. Anybody knows why this was the problem?
-Samik

On 7/27/2003 6:51 PM, Samik Raychaudhuri wrote:
[color=blue]
> Hello,
> I am having the following XML file:
> -----
> <bibRecords xmlns="http://tempuri.org/bibrecords.xsd">
> <bibRecord>
> <entryID>1</entryID>
> <tag>Shioura97</tag>
> <entrytype>Conference Proceedings</entrytype>
> </bibRecord>
> </bibRecord>
> ------
>
> Dim oNode As Xml.XmlNodeList
> oNodes = xmldoc.SelectNodes("/bibRecords/bibRecord[entryID='1']")
>
> The above 2 lines is returning oNodes.count=0, whereas the following line:
>
> oNodes = xmldoc.GetElementsByTagName("bibRecord")
>
> is returning oNodes.count=1 as expected. Seems like I am making some
> stupid mistake in the Xpath query, or may be missing something. Can
> somebody point it out?
> Thanks and regards,[/color]

 
Not the answer you were looking for? Post your question . . .
196,841 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,841 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors