473,386 Members | 1,835 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.

C# VS 2005 : Reading XML file doesn't work

Hi ;-)

I have created a .aspx file that has the following:

DataSet ds = new DataSet();

ds.ReadXml(Server.MapPath("TestInput.xml"));

As far as I can tell, the first line does not work - at all. I just get
"error" in the status field of the browser. How can I check to see what
the problem is for it not executing? I don't know how to check the
return code or use the debugger with this.

Is there something wrong with what I have written altogether?

TIA

Nov 19 '05 #1
4 955
Have you considered using an XmlDataSource control ?

http://beta.asp.net/QUICKSTART/util/...TreeView12.src

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"milkyway" <d0******@hotmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
Hi ;-)

I have created a .aspx file that has the following:

DataSet ds = new DataSet();

ds.ReadXml(Server.MapPath("TestInput.xml"));

As far as I can tell, the first line does not work - at all. I just get
"error" in the status field of the browser. How can I check to see what
the problem is for it not executing? I don't know how to check the
return code or use the debugger with this.

Is there something wrong with what I have written altogether?

TIA

Nov 19 '05 #2
I was following the examples I had seen on the internet to make the
code work.

I had wanted to get a list of the items on the server and manipulate
the list (on the server).

Is there something I did wrong with what I have used? Is there a pit
that I fell into (perhaps with the creation of the .xml) that would
cause problems? Should I place .xml files in a different directory?

I guess I am kinda lost here as to where I can look for the problem or
how one might use the debugger to track it down ;-(

Nov 19 '05 #3
re:
Is there something I did wrong with what I have used?
The two lines of code you sent are not enough to determine that.

Offhand, did you import the system.data namespace ?

<%@ Import Namespace="System.Data" %>

re: Is there a pit that I fell into (perhaps with the creation of the .xml)
that would cause problems?
It's hard to tell unless you post the xml itself
or run the xml file through an xml validator.

If you want to do the latter, Peter's XML Editor will tell you
if the file's XML is well-formed when you attempt to load it.

Get it at : http://www.iol.ie/~pxe/index.html

re: Should I place .xml files in a different directory?
You might as well, since with ASP.NET 2.0 xml data goes in the App_Data dir.

re:I was following the examples I had seen on the internet to make the
code work.
The thing is that data access examples "on the internet", and particularly examples
of binding to xml datasources, are unnecessarily complicated and, if all you want
to do is display the contents of an xml file, just place your xml file in your
application's App_Data directory ( if one doesn't exist, create it ), change
the Datafile's name to your XML's filename, and run this extremely short sample :

ShowXML.aspx:
------------------
<%@ Page Language="VB"%>
<html>
<body>
<form id="showXML" runat="server">
<asp:XmlDataSource id="MySource" DataFile="~/App_Data/your.xml" runat="server"/>
<asp:TreeView
SkinId="Bookstore"
DataSourceId="MySource"
ExpandDepth="3"
MaxDataBindDepth="3"
runat="server"
/>
</form>
</body>
</html>
----------

Easier access to XML data sources is one of
the benefits which ASP.NET 2.0 brings us.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"milkyway" <d0******@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...I was following the examples I had seen on the internet to make the
code work.

I had wanted to get a list of the items on the server and manipulate
the list (on the server).

Is there something I did wrong with what I have used? Is there a pit
that I fell into (perhaps with the creation of the .xml) that would
cause problems? Should I place .xml files in a different directory?

I guess I am kinda lost here as to where I can look for the problem or
how one might use the debugger to track it down ;-(

Nov 19 '05 #4
Thanks response Juan - I found the problem ;-P

Basically, the C# code I wrote was to create a .html file for display.
But - what I forgot were the directives so that the C# could run in
peace. When I did:

<%

DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("TestInput.xml"));
%>

Then it worked ;-)

Nov 19 '05 #5

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

Similar topics

6
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
8
by: | last post by:
I'm starting up the development server myself and using the "Startup Url" property of the web project. The problem is i cannot debug. The debug symbols are never loaded. I realize they are under...
0
by: Mart | last post by:
Hi, I have just written (my first) VB.net app using MS Visual Basic 2005 Express Edition Beta. It is fairly simple, it reads some configuration data from an XML file then opens a new window...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.