xpath problems

Discussion in 'ASP .Net' started by Marri Suliez, Jan 15, 2004.

  1. Marri Suliez

    Marri Suliez Guest

    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?
     
    Marri Suliez, Jan 15, 2004
    #1
    1. Advertising

  2. 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
     
    Oleg Tkachenko, Jan 15, 2004
    #2
    1. Advertising

  3. Marri Suliez

    Marri Suliez Guest

    Oleg Tkachenko <oleg@no_!spam!_please!tkachenko.com> wrote in
    news:e32dU#:

    > 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.
     
    Marri Suliez, Jan 15, 2004
    #3
  4. 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
     
    Oleg Tkachenko, Jan 18, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,974
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,414
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    526
  4. goog
    Replies:
    0
    Views:
    508
  5. Tjerk Wolterink

    XPath: efficiency in xpath expressions

    Tjerk Wolterink, Nov 13, 2004, in forum: XML
    Replies:
    1
    Views:
    1,639
    Richard Tobin
    Nov 13, 2004
Loading...

Share This Page