Re: Hexadeciaml Error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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





.



Relevant Pages

  • Re: Hexadeciaml Error
    ... //convert 5 empty bytes to string ... StreamWriter sw = new StreamWriter; ... It's strange however that you read the same xml on the second shot... ... It may happen if you forgot to "Re-position" input streams before ...
    (microsoft.public.dotnet.framework.compactframework)
  • >>>> XML DOWNLOAD <<<<
    ... access 2007 ribbon tool download xml, ... microsoft 4.0 xml parser, download microsoft xml validation, download ...
    (comp.protocols.snmp)
  • Ping= Lucy [MSFT] =
    ... none of them mentioned any thing about stylesheets or XML document!! ... Try installing updates again. ... I know that there are some of them are already installed with Windows XP Pro and with Service packs and updates.. ... There are three options to download MSXML 3.0 SP4: ...
    (microsoft.public.windowsxp.general)
  • Re: Proposal: Delphi VCL+RTL as open source
    ... where to download all those changes/patches/improvements from. ... Open sourcing the product is certainly not required for this. ... I use Cds.SaveToFile/LoadFromFile using XML ... What I would prefer is in each Delphi help topic (for instance ...
    (borland.public.delphi.non-technical)
  • nntplib downloads content with extra linebreaks
    ... I am using nntplib to download archived xml messages from our internal newsgroup. ... This is working fine except the download of files to the connected server, ...
    (comp.lang.python)