XmlDocument LoadXml

M

Martin Honnen

Lupina wrote:

I want load whole xml file, I try do it in the same way as I did it in
windows application.

try

{

XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(Server.MapPath("cars.xml"));

You need to use the method Load which loads from a file or URL and not
the method LoadXml which is supposed to load the XML from a string so try
myDoc.Load(Server.MapPath("cars.xml"));
 
L

Lupina

Hi
I want load whole xml file, I try do it in the same way as I did it in
windows application.

try

{

XmlDocument myDoc = new XmlDocument();

myDoc.LoadXml(Server.MapPath("cars.xml"));

}

catch ( Exception err )

{

message.Text = err.Message + err.StackTrace;

}

but I get error :

The data at the root level is invalid. Line 1, position 1

at System.Xml.XmlTextReader.ParseRoot() at System.Xml.XmlTextReader.Read()
at System.Xml.XmlValidatingReader.ReadWithCollectTextToken() at
System.Xml.XmlValidatingReader.Read() at
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean
preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at
System.Xml.XmlDocument.LoadXml(String xml) at
myHoQ.WebForm1.ButtonCreate_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\myhoq\index.aspx.cs:line 66



line 66 :

myDoc.LoadXml(Server.MapPath("cars.xml"));

I'm new in asp.net. I don't konw why it works in C#(application) and
doesn't i asp.net. (Can we use DOM?)

Thanks
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top