Home All Groups Group Topic Archive Search About
Author
23 Dec 2005 7:24 AM
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???

Author
23 Dec 2005 9:32 AM
Hans Kesting
Show quote Hide quote
> 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

Bookmark and Share