Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > xpath problems

Reply
Thread Tools

xpath problems

 
 
Marri Suliez
Guest
Posts: n/a
 
      01-15-2004
I am trying to run the asp xpath examples from the QuickStarts samples, but
I am not having any luck. When I run the code in a console app it works
fine. When I run the same exact code in an aspx page it doesn't work.

Here's a condensed example of what I am talking about. If I run this code
in a console app the "count" variable will have a value equal to the number
of book nodes in "books.xml". When I run the same code in an aspx page the
count is always 0.

XPathDocument doc = new XPathDocument("books.xml");
XPathNavigator navigator = doc.CreateNavigator();
XPathNodeIterator iterator = navigator.Select("bookstore/book");
int count = iteractor.Count;

Any ideas?
 
Reply With Quote
 
 
 
 
Oleg Tkachenko
Guest
Posts: n/a
 
      01-15-2004
Marri Suliez wrote:

> I am trying to run the asp xpath examples from the QuickStarts samples, but
> I am not having any luck. When I run the code in a console app it works
> fine. When I run the same exact code in an aspx page it doesn't work.
>
> Here's a condensed example of what I am talking about. If I run this code
> in a console app the "count" variable will have a value equal to the number
> of book nodes in "books.xml". When I run the same code in an aspx page the
> count is always 0.
>
> XPathDocument doc = new XPathDocument("books.xml");


Most likely it has nothing to do with XPath. Whenever you are working
with file system in ASP.NET, use Server.MapPath to get files. Try
XPathDocument doc = new XPathDocument(Server.MapPath("books.xml"));
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
 
Reply With Quote
 
 
 
 
Marri Suliez
Guest
Posts: n/a
 
      01-15-2004
Oleg Tkachenko <oleg@no_!spam!_please!tkachenko.com> wrote in
news:e32dU#(E-Mail Removed):

> Most likely it has nothing to do with XPath. Whenever you are working
> with file system in ASP.NET, use Server.MapPath to get files. Try
> XPathDocument doc = new XPathDocument(Server.MapPath("books.xml"));


I already am doing that. If I wasn't I'd be getting an exception because
the file wouldn't be located. I'm not getting an error. The XPathDocument
is getting loaded properly. The problem comes in when I try call
XPathNavigator.Select.
 
Reply With Quote
 
Oleg Tkachenko
Guest
Posts: n/a
 
      01-18-2004
Marri Suliez wrote:

> I already am doing that. If I wasn't I'd be getting an exception because
> the file wouldn't be located. I'm not getting an error. The XPathDocument
> is getting loaded properly. The problem comes in when I try call
> XPathNavigator.Select.


Now that weird. Make sure you it's the same document and exactly the
same code that works in command line.
--
Oleg Tkachenko
XmlInsider
http://blog.tkachenko.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments