XML Exception

  • Thread starter Thread starter shil
  • Start date Start date
S

shil

In my project I have to read XML files I collect from people. Some of
the XML files have weird characters in the date format, due to which I
get an exception on the ReadXml method of the dataset.

I have this code in Framework 2.0.

Dim objDSXML As New DataSet
objDSXML.ReadXml("\Config.xml")

I get System.Xml.XmlException {"Invalid character in the given
encoding. Line 13, position 27."}

My Config.xml files looks like this.

<?xml version="1.0" ?>
<configuration>
<Node1>0</Node1>
<LN></LN>
<pd>12345</pd>
<Number>13842</Number>
<Type>5000</Type>
<ID></ID>
<pass></pass>
<phoneNo></phoneNo>
<status>1</status>
<createdBy>me</createdBy>
<createdDate>2007-04-23 ?�후 6:01:52</createdDate>
<Factors></Factors>
<Name></Name>
</configuration>

It is very rare that I get this corrupted date format. But I have to
handle this with code and escape from moving froward if I get a file
like this.

Can any one help me with this?
 
Your XML has invalid characters in it. You need to encode the characters
correctly in the XML. Remember that XML is strict. I simply won't fly if
there are illegal characters in it. The following article explains how to do
this.

http://www.xml.com/pub/a/2001/01/31/qanda.html

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

In my project I have to read XML files I collect from people. Some of
the XML files have weird characters in the date format, due to which I
get an exception on the ReadXml method of the dataset.

I have this code in Framework 2.0.

Dim objDSXML As New DataSet
objDSXML.ReadXml("\Config.xml")

I get System.Xml.XmlException {"Invalid character in the given
encoding. Line 13, position 27."}

My Config.xml files looks like this.

<?xml version="1.0" ?>
<configuration>
<Node1>0</Node1>
<LN></LN>
<pd>12345</pd>
<Number>13842</Number>
<Type>5000</Type>
<ID></ID>
<pass></pass>
<phoneNo></phoneNo>
<status>1</status>
<createdBy>me</createdBy>
<createdDate>2007-04-23 ??? 6:01:52</createdDate>
<Factors></Factors>
<Name></Name>
</configuration>

It is very rare that I get this corrupted date format. But I have to
handle this with code and escape from moving froward if I get a file
like this.

Can any one help me with this?
 
Back
Top