System.Xml.XmlException

M

mohit

Hi,
I am making a web application in Web Matrix on .NET framework.
I have a Login.aspx File and a Users.xml file.I am reading data
from Users.xml file using FileStream.The Code is

DataSet ds = new DataSet ( );

FileStream fs = new FileStream ( Server.MapPath ( "Users.xml"
),

FileMode.Open,FileAccess.Read );
StreamReader reader = new StreamReader ( fs );
ds.ReadXml ( reader );
reader.Close();
fs.Close ( );

it gives the following error :

System.Xml.XmlException: This is an unexpected token. Expected
'EndElement'. Line 10, position 5.

Where is the mistake in my code?

any Ideas???
 
H

Hans Kesting

Hi,
I am making a web application in Web Matrix on .NET framework.
I have a Login.aspx File and a Users.xml file.I am reading data
from Users.xml file using FileStream.The Code is

DataSet ds = new DataSet ( );

FileStream fs = new FileStream ( Server.MapPath ( "Users.xml"
),

FileMode.Open,FileAccess.Read );
StreamReader reader = new StreamReader ( fs );
ds.ReadXml ( reader );
reader.Close();
fs.Close ( );

it gives the following error :

System.Xml.XmlException: This is an unexpected token. Expected
'EndElement'. Line 10, position 5.

Where is the mistake in my code?

any Ideas???

The error seems to say the XML isn't formatted correctly.
Try opening it in IE, that might show you the error.

Apart from that, you could also use:
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath ( "Users.xml"));

(but this will fail on that same error, but maybe with a more helpful
message)

Hans Kesting
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top