Hi,
I have a button that, when clicked, saves all the info entered. It worked
fine until suddenly it didn't, and I have no idea why. I get the error
An unhandled exception of type 'System.Xml.XmlException' occurred in
system.xml.dll
Additional information: System error.
I found that this sometimes happens when there's some unrecognized
character, so I even started with a new xml file, but it still won't work.
It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any
ideas on why this would suddenly stop working?
Thanks,
Mel
Here's some code:
string cat = @"C:\Catalog4.xml";
XmlDocument xml = new XmlDocument();
xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File");
file.InnerText = number.ToString();
Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust");
eCust.InnerText = cust;
file.AppendChild(eCust);
xml.Save(cat); 12 1710
melanieab wrote: I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
The Load method parses the XML and throws an exception if the markup is
not well formed:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlDocumentClassLoadTopic2.asp>
So catch the exception e.g.
try {
xml.Load(cat);
}
catch (XmlException e) {
// now check e.Message, e.LineNumber, e.LinePosition here to
// find out why the XML parser can't parse your markup e.g.
}
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Hi Melanieab,
can you include a copy of what is inside your Catalog4.xml file, that
might help explain more precisely what your problem is.
Mark R Dawson
"melanieab" wrote: Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
I found that this sometimes happens when there's some unrecognized character, so I even started with a new xml file, but it still won't work. It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any ideas on why this would suddenly stop working? Thanks, Mel
Here's some code: string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File"); file.InnerText = number.ToString(); Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust"); eCust.InnerText = cust; file.AppendChild(eCust); xml.Save(cat);
Actually now, after playing around with other sections of the code, it seems
I can't use xml at all anymore. At the beginning, I declare a private
DataTable tCat, then later when I want to load the info into a datagrid, I
say tCat = new DataTable (which worked fine before), but now I get the same
error message as below. I have no idea what's going on.
"Martin Honnen" wrote:
melanieab wrote:
I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
The Load method parses the XML and throws an exception if the markup is not well formed: <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlDocumentClassLoadTopic2.asp> So catch the exception e.g. try { xml.Load(cat); } catch (XmlException e) { // now check e.Message, e.LineNumber, e.LinePosition here to // find out why the XML parser can't parse your markup e.g. }
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
melanieab wrote: I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
The Load method parses the XML and throws an exception if the markup is
not well formed:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlDocumentClassLoadTopic2.asp>
So catch the exception e.g.
try {
xml.Load(cat);
}
catch (XmlException e) {
// now check e.Message, e.LineNumber, e.LinePosition here to
// find out why the XML parser can't parse your markup e.g.
}
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Hi Melanieab,
can you include a copy of what is inside your Catalog4.xml file, that
might help explain more precisely what your problem is.
Mark R Dawson
"melanieab" wrote: Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
I found that this sometimes happens when there's some unrecognized character, so I even started with a new xml file, but it still won't work. It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any ideas on why this would suddenly stop working? Thanks, Mel
Here's some code: string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File"); file.InnerText = number.ToString(); Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust"); eCust.InnerText = cust; file.AppendChild(eCust); xml.Save(cat);
I've tried a few files. This one is Catalog4 (it's just empty except for
what was automatically generated):
<?xml version="1.0" encoding="utf-8" ?>
and I keep getting that same system error when trying to load
string cat = @"C:\Catalog4.xml";
XmlDocument xml = new XmlDocument();
xml.Load(cat);
Next, here's Catalog3:
<?xml version="1.0" encoding="utf-8" ?>
<Catalog>
<File ID="1">
<Cust>mrn</Cust>
<CI>400</CI>
<Date>8/8/2005 2:56:45 PM</Date>
</File>
</Catalog>
Finally, this was my original one (Catalog2) where it just stopped working
after I decided I didn't want to use attributes and changed it from the
format in 3 to this one:
<?xml version="1.0" encoding="utf-8"?>
<Catalog>
<File>1<File>
<Cust>mrn</Cust>
<CI>400</CI>
<Date>8/8/2005 2:56:45 PM</Date>
<File>2<File>
<Cust>mab</Cust>
<CI>444</CI>
<Date>8/8/2005 2:58:23 PM</Date>
</Catalog>
Thanks for looking at it!!!
Mel
"Mark R. Dawson" wrote: Hi Melanieab, can you include a copy of what is inside your Catalog4.xml file, that might help explain more precisely what your problem is.
Mark R Dawson
"melanieab" wrote:
Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
I found that this sometimes happens when there's some unrecognized character, so I even started with a new xml file, but it still won't work. It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any ideas on why this would suddenly stop working? Thanks, Mel
Here's some code: string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File"); file.InnerText = number.ToString(); Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust"); eCust.InnerText = cust; file.AppendChild(eCust); xml.Save(cat);
Actually now, after playing around with other sections of the code, it seems
I can't use xml at all anymore. At the beginning, I declare a private
DataTable tCat, then later when I want to load the info into a datagrid, I
say tCat = new DataTable (which worked fine before), but now I get the same
error message as below. I have no idea what's going on.
"Martin Honnen" wrote:
melanieab wrote:
I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
The Load method parses the XML and throws an exception if the markup is not well formed: <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlDocumentClassLoadTopic2.asp> So catch the exception e.g. try { xml.Load(cat); } catch (XmlException e) { // now check e.Message, e.LineNumber, e.LinePosition here to // find out why the XML parser can't parse your markup e.g. }
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
I've tried a few files. This one is Catalog4 (it's just empty except for
what was automatically generated):
<?xml version="1.0" encoding="utf-8" ?>
and I keep getting that same system error when trying to load
string cat = @"C:\Catalog4.xml";
XmlDocument xml = new XmlDocument();
xml.Load(cat);
Next, here's Catalog3:
<?xml version="1.0" encoding="utf-8" ?>
<Catalog>
<File ID="1">
<Cust>mrn</Cust>
<CI>400</CI>
<Date>8/8/2005 2:56:45 PM</Date>
</File>
</Catalog>
Finally, this was my original one (Catalog2) where it just stopped working
after I decided I didn't want to use attributes and changed it from the
format in 3 to this one:
<?xml version="1.0" encoding="utf-8"?>
<Catalog>
<File>1<File>
<Cust>mrn</Cust>
<CI>400</CI>
<Date>8/8/2005 2:56:45 PM</Date>
<File>2<File>
<Cust>mab</Cust>
<CI>444</CI>
<Date>8/8/2005 2:58:23 PM</Date>
</Catalog>
Thanks for looking at it!!!
Mel
"Mark R. Dawson" wrote: Hi Melanieab, can you include a copy of what is inside your Catalog4.xml file, that might help explain more precisely what your problem is.
Mark R Dawson
"melanieab" wrote:
Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
I found that this sometimes happens when there's some unrecognized character, so I even started with a new xml file, but it still won't work. It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any ideas on why this would suddenly stop working? Thanks, Mel
Here's some code: string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File"); file.InnerText = number.ToString(); Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust"); eCust.InnerText = cust; file.AppendChild(eCust); xml.Save(cat);
Hi Melanieab,
I am not sure if you mistyped this for your reply but the XML: <?xml version="1.0" encoding="utf-8"?> <Catalog> <File>1<File> <Cust>mrn</Cust> <CI>400</CI> <Date>8/8/2005 2:56:45 PM</Date> <File>2<File> <Cust>mab</Cust> <CI>444</CI> <Date>8/8/2005 2:58:23 PM</Date> </Catalog>
has an invalid <File> tag, the closing bracket is not correct, you have
<File>1<File> when it should be <File>1</File> this would definitely cause
an exception when you try to load the XML and the document tries to parse the
XML.
For your catalog4.xml file, if all it contains is:
<?xml version="1.0" encoding="utf-8" ?>
then an exception will be thrown because there is no document for the XML
document to load, it fails trying to parse the data on the Load method call,
if you have something like:
<?xml version="1.0" encoding="utf-8" ?>
<myRootElement />
then this will load okay. Basically make sure in your code that you always
have a root element in your XML file even if you do not have anything to put
inside it.
Hope that helps
Mark R Dawson
"melanieab" wrote:
I've tried a few files. This one is Catalog4 (it's just empty except for what was automatically generated):
<?xml version="1.0" encoding="utf-8" ?>
and I keep getting that same system error when trying to load string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
Next, here's Catalog3:
<?xml version="1.0" encoding="utf-8" ?> <Catalog> <File ID="1"> <Cust>mrn</Cust> <CI>400</CI> <Date>8/8/2005 2:56:45 PM</Date> </File> </Catalog>
Finally, this was my original one (Catalog2) where it just stopped working after I decided I didn't want to use attributes and changed it from the format in 3 to this one:
<?xml version="1.0" encoding="utf-8"?> <Catalog> <File>1<File> <Cust>mrn</Cust> <CI>400</CI> <Date>8/8/2005 2:56:45 PM</Date> <File>2<File> <Cust>mab</Cust> <CI>444</CI> <Date>8/8/2005 2:58:23 PM</Date> </Catalog>
Thanks for looking at it!!! Mel "Mark R. Dawson" wrote:
Hi Melanieab, can you include a copy of what is inside your Catalog4.xml file, that might help explain more precisely what your problem is.
Mark R Dawson
"melanieab" wrote:
Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
I found that this sometimes happens when there's some unrecognized character, so I even started with a new xml file, but it still won't work. It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any ideas on why this would suddenly stop working? Thanks, Mel
Here's some code: string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File"); file.InnerText = number.ToString(); Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust"); eCust.InnerText = cust; file.AppendChild(eCust); xml.Save(cat);
Hi Melanieab,
I am not sure if you mistyped this for your reply but the XML: <?xml version="1.0" encoding="utf-8"?> <Catalog> <File>1<File> <Cust>mrn</Cust> <CI>400</CI> <Date>8/8/2005 2:56:45 PM</Date> <File>2<File> <Cust>mab</Cust> <CI>444</CI> <Date>8/8/2005 2:58:23 PM</Date> </Catalog>
has an invalid <File> tag, the closing bracket is not correct, you have
<File>1<File> when it should be <File>1</File> this would definitely cause
an exception when you try to load the XML and the document tries to parse the
XML.
For your catalog4.xml file, if all it contains is:
<?xml version="1.0" encoding="utf-8" ?>
then an exception will be thrown because there is no document for the XML
document to load, it fails trying to parse the data on the Load method call,
if you have something like:
<?xml version="1.0" encoding="utf-8" ?>
<myRootElement />
then this will load okay. Basically make sure in your code that you always
have a root element in your XML file even if you do not have anything to put
inside it.
Hope that helps
Mark R Dawson
"melanieab" wrote:
I've tried a few files. This one is Catalog4 (it's just empty except for what was automatically generated):
<?xml version="1.0" encoding="utf-8" ?>
and I keep getting that same system error when trying to load string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
Next, here's Catalog3:
<?xml version="1.0" encoding="utf-8" ?> <Catalog> <File ID="1"> <Cust>mrn</Cust> <CI>400</CI> <Date>8/8/2005 2:56:45 PM</Date> </File> </Catalog>
Finally, this was my original one (Catalog2) where it just stopped working after I decided I didn't want to use attributes and changed it from the format in 3 to this one:
<?xml version="1.0" encoding="utf-8"?> <Catalog> <File>1<File> <Cust>mrn</Cust> <CI>400</CI> <Date>8/8/2005 2:56:45 PM</Date> <File>2<File> <Cust>mab</Cust> <CI>444</CI> <Date>8/8/2005 2:58:23 PM</Date> </Catalog>
Thanks for looking at it!!! Mel "Mark R. Dawson" wrote:
Hi Melanieab, can you include a copy of what is inside your Catalog4.xml file, that might help explain more precisely what your problem is.
Mark R Dawson
"melanieab" wrote:
Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
I found that this sometimes happens when there's some unrecognized character, so I even started with a new xml file, but it still won't work. It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any ideas on why this would suddenly stop working? Thanks, Mel
Here's some code: string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File"); file.InnerText = number.ToString(); Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust"); eCust.InnerText = cust; file.AppendChild(eCust); xml.Save(cat);
To see if the xml is valid, you can open the xml in IE or any browser (that
ships with a parser). The browser will display the part of the file which has
invaild tags. If the XML is valid then the entire XML will be displayed as a
tree.
Thanks,
Manoj
"melanieab" wrote: Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
I found that this sometimes happens when there's some unrecognized character, so I even started with a new xml file, but it still won't work. It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any ideas on why this would suddenly stop working? Thanks, Mel
Here's some code: string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File"); file.InnerText = number.ToString(); Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust"); eCust.InnerText = cust; file.AppendChild(eCust); xml.Save(cat);
To see if the xml is valid, you can open the xml in IE or any browser (that
ships with a parser). The browser will display the part of the file which has
invaild tags. If the XML is valid then the entire XML will be displayed as a
tree.
Thanks,
Manoj
"melanieab" wrote: Hi, I have a button that, when clicked, saves all the info entered. It worked fine until suddenly it didn't, and I have no idea why. I get the error An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error.
I found that this sometimes happens when there's some unrecognized character, so I even started with a new xml file, but it still won't work. It yells at me when I try to say XmlNode Catalog = xml.DocumentElement. Any ideas on why this would suddenly stop working? Thanks, Mel
Here's some code: string cat = @"C:\Catalog4.xml"; XmlDocument xml = new XmlDocument(); xml.Load(cat);
XmlNode Catalog = xml.DocumentElement; (green error arrow here)
XmlElement file = xml.CreateElement("File"); file.InnerText = number.ToString(); Catalog.AppendChild(file);
XmlElement eCust = xml.CreateElement("Cust"); eCust.InnerText = cust; file.AppendChild(eCust); xml.Save(cat); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matt Rapoport |
last post by:
I'm running an NT service with a thread. The thread performs a
calculation every so often and appends the number to a text file.
Every so often the thread just stops - or so it seems. The text...
|
by: Dean J. Garrett |
last post by:
We've had a small Access database driving a website using ASP code for a
couple of years now. About 2 months ago, the code would intermittantly get
database access errors like the one below. It...
|
by: Adam |
last post by:
Hi!
I've modified a javascript order form calculation script that tallies
up the subtotal, shipping/handling, and total automatically.
I did some modifications and it still worked fine, even...
|
by: allenj |
last post by:
DB2 UDB 7.2 WSE
Fixpak 9
Linux Red Hat 7.3
A very strange thing just happened w/ my DB2 server. I am on Linux and
using NIS - the instance owner is in the servers /etc/passwd file.
Suddenly,...
|
by: Michiel Rapati-Kekkonen |
last post by:
Sometimes it happens that an application that worked well before
starts to complain.
All kind of simple commands seem suddenly to be ununderstandable.
I then check the list of 'references', if I...
| |
by: Roman Mashak |
last post by:
Hello, All!
I faced with unknown problem for me, hopefully local guru can help me out.
#define MSGLEN 32
#define BUFFLEN 1024
typedef struct msg_s {
unsigned char msg_flag;...
|
by: melanieab |
last post by:
Hi,
I'd been saying DataGrid.HitTestInfo HitInfo = dg.HitTest(e.X, e.Y); for a
while without any problem (of course with using System.Windows.Forms;). Then
suddently I got errors and had to add...
|
by: Pieter |
last post by:
Hi,
I developed an Outlook Add In (VB.NET 2005, for Outlook 2003) that sometimes
suddenly stops loading. I've put everywhere in the code Exception Handlers,
but no Exception is catched.
it...
|
by: =?Utf-8?B?TGlzYUxHSw==?= |
last post by:
Yesterday Outlook stopped working on my computer. All I get is an error
message saying "Cannot open the Outlook window. The set folders cannot be
opened. Errors have been detected in the file. Use...
|
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,...
|
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...
| |
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,...
|
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...
|
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,...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |