473,748 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Xml.XmlE xception

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,F ileAccess.Read );
StreamReader reader = new StreamReader ( fs );
ds.ReadXml ( reader );
reader.Close();
fs.Close ( );

it gives the following error :

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

Where is the mistake in my code?

any Ideas???

Dec 23 '05 #1
1 2336
> 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,F ileAccess.Read );
StreamReader reader = new StreamReader ( fs );
ds.ReadXml ( reader );
reader.Close();
fs.Close ( );

it gives the following error :

System.Xml.XmlE xception: 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
Dec 23 '05 #2

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

Similar topics

0
1215
by: George CK | last post by:
Hello, I tried to send an xml string got from XmlTextReader from a web service proxy to a web service. The type of the web method is simply "string" It's fine when the string length was small enough (probably < 1024), but when I send a longer one, I got an XmlException Exception on my client side.
3
22367
by: Todd | last post by:
Our ASP.NET (C#) application accepts form entry and saves inputed data in XML. We are finding that users are sometimes cutting and pasting special characters (from MS Word) into these forms. The data is saved successfuly, but when the XML is later read the following error is encountered depending on the invalid character found: This is a sample:
0
3292
by: Franck | last post by:
Hello, here is my basic dtd <!ELEMENT TREENODES (treenode*)> <!ELEMENT treenode (treenode*)> <!ATTLIST treenode Text (#PCDATA) #REQUIRED Level (#PCDATA) #REQUIRED NodeData (#PCDATA) #REQUIRED>
0
3342
by: Frederico Guimar?es via DotNetMonster.com | last post by:
Hi, I'm trying to use the Microsoft.Web.Services2.Messaging. ISoapFormatter but I receive this error: System.Xml.XmlException: The root element is missing. at System.Xml.XmlTextReader.Read() at Microsoft.Web.Services2.Xml.XmlSkipDTDReader.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
1
9424
by: marcmc | last post by:
The code is below but I'm 99.9% sure that the code is okay and that maybe the schema has become corrupt somehow and im not sure how to fix it? Private Function LoadXMLSchema() 'Dim fileName As String = "C:\Documents and Settings\marc.mcguckian\My Documents\Visual Studio Projects\MIS RECON Engine\MISRE_XMLSchema.xsd" Dim fileName As String = "F:\QDIMIS_RECON_Logs\config\MISRE_XMLSchema.xsd"
0
1894
by: Ramon de Klein | last post by:
I try to serialize an exception using the SoapFormatter, but this is a little bit problematic. The MethodInfo tag of the serialized exception contains &x00 characters (ASCII 0x00) in its serialized data. When the data is deserialized on the client side the SoapHttpClientProtocol.ReadResponse uses an XmlTextReader with Normalization switched on. In that case the &x00 character is not valid and results in the following XmlException: ...
1
2161
by: BLUE | last post by:
In a property i do this: .... catch(XmlException e) { throw new XmlException("Error processing configuration file!",e); } Then I catch it in another class: catch(XmlException e) {
1
11578
by: ayemyat | last post by:
Hi All, I have a remoting service which consumes the web service in another server. I have the following exception throw by the web service. System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1. There is an error in XML document (0, 0). &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;MSVBalanceEnquiry xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt; ...
3
3535
by: =?Utf-8?B?RWQgS3JhbWVy?= | last post by:
I thought this might be useful for someone... I was doing a little work earlier using an Xmldocument class to create & maintain a minor store of data in Xml format. I'd gotten the whole thing up and going and I decided to start testing 'disaster' scenarios. For example, you start up but your file has been deleted, or you try to save and the file is read only. Or you lack write permissions. Or you try to load
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.