Re: Hexadeciaml Error
- From: "MDB" <nospam>
- Date: Mon, 20 Feb 2006 07:05:21 -0500
Hi, Thanks again for your response. The order.xml is the same on all
devices, they all download it from a FTP site each night and then read it
into a dataset to be saved. I will try playing around with it some more to
see if I can narrow it down. I am starting to think that maybe the file is
getting corrupted when downloaded. What makes it difficult is that I never
happens when I debug.
Thanks Again
"Ruslan Trifonov" <ruslan.trifonov@xxxxxxxxxxxxxxx> wrote in message
news:aa93ca899e38c80232070e41b0@xxxxxxxxxxxxxxxxxxxxx
I can't tell what is your exact problem;however I may give you a code that
produces the same problem
//create 5 empty bytes
byte[] b = new byte[5];
//convert 5 empty bytes to string
string evilXmlChars=System.Text.Encoding.UTF8.GetString(b, 0,
b.Length);
//create bad xml FileStream fs = new FileStream("\\badxml.xml",
FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.Write("<root>" + evilXmlChars + "</root>");
sw.Flush();
fs.Close();
//try to read it...
fs = new FileStream("\\badxml.xml", FileMode.Open);
DataSet ds = new DataSet();
//BOOOM - this is where you'll get exception: '' '',
hexadecimal value 0x00, is an invalid character
ds.ReadXml(fs);
fs.Close();
You may see in the debuger that evilXmlChars contains \0\0\0\0\0 .... and
that is exactly what the exception message says.
So I suggest digging into orders.xml file for such a char seqence.
It's strange however that you read the same xml on the second shot...
Is the order.xml one and the same on all devices or your application
generates it on the device?
What I mean with "re-positioning" is the following:
Having empty buffer may happen when you dealing with streams/buffers and
accidently you haven't set the right Stream.Poistion...but that was just a
guess.
Ruslan Trifonov
http://xman892.blgostpot.com
Hi thanks for your response. The xml does not have any nulls or 0X00.
Also, I read the XML like this:
ds.ReadXml(Common.Classes.Globals.gstrUpdateFolderPath +
"orders.xml");
How to I "Re-position" the input?
"Ruslan Trifonov" <ruslan.trifonov@xxxxxxxxxxxxxxx> wrote in message
news:7d86b7127dbc8c801d8ba6500c7@xxxxxxxxxxxxxxxxxxxxx
Check if the Xml content that you read is a valid xml and not full
of
0x00
It may happen if you forgot to "Re-position" input streams before
reading/writing xml
Ruslan Trifonov
.
- References:
- Re: Hexadeciaml Error
- From: MDB
- Re: Hexadeciaml Error
- From: Ruslan Trifonov
- Re: Hexadeciaml Error
- Prev by Date: Re: Compatibility Tool
- Next by Date: Re: Build & Deployment problem.
- Previous by thread: Re: Hexadeciaml Error
- Next by thread: OpenNetCF CSP
- Index(es):
Relevant Pages
|