Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   xpath problems (http://www.velocityreviews.com/forums/t70706-xpath-problems.html)

Marri Suliez 01-15-2004 11:06 PM

xpath problems
 
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?

Oleg Tkachenko 01-15-2004 11:30 PM

Re: xpath problems
 
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

Marri Suliez 01-15-2004 11:55 PM

Re: xpath problems
 
Oleg Tkachenko <oleg@no_!spam!_please!tkachenko.com> wrote in
news:e32dU#72DHA.2296@TK2MSFTNGP11.phx.gbl:

> 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.

Oleg Tkachenko 01-18-2004 11:39 AM

Re: xpath problems
 
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


All times are GMT. The time now is 02:42 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.