473,386 Members | 1,734 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 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?
Nov 18 '05 #1
3 974
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
Nov 18 '05 #2
Oleg Tkachenko <oleg@no_!spam!_please!tkachenko.com> wrote in
news:e3**************@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.
Nov 18 '05 #3
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
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
13
by: tfsquare | last post by:
All, I am new to XSLT and having some problems understanding the syntax of XPath which selects nodes in the XML document. Consider this bit of XML, which contains three outer XML elements. ...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
2
by: Anna | last post by:
Hi all. I am using Jaxen to evaluate XPath expressions in Java. I encountered problems when comparing results returned by jaxen with results returned by other XPath implementation - I was using...
4
by: Vitali Gontsharuk | last post by:
Hallo! When using the XPATH document() function to load a new XML document, we are coming across problems, because XALAN seems to have problems with absolute paths. XALAN always assumes that the...
2
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
5
by: Chua Wen Ching | last post by:
Hi, I read from this tutorial at codeproject Question A: http://www.codeproject.com/csharp/GsXPathTutorial.asp regarding xpath.. but i try to apply in my situation, and can't get it...
14
by: Mat| | last post by:
Hello :-) I am learning XPath, and I am trying to get child nodes of a node whose names do *not* match a given string, e.g : <dummy> <example> <title>Example 1</title> <body>this is an...
7
by: Tim Hallwyl | last post by:
Hi, there! As I understand the XPaht recommendation, the context node is a node; not a node-list, not XPath object -- but a single node. Now, the WS-BPEL 2.0 specification allows an XML simple...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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:
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.