473,396 Members | 2,030 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,396 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 17 '05 #1
4 1016
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 17 '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 17 '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 17 '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 17 '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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.