XML反序列化器看到零长度文件,“根元素丢失” [英] XML deserializer sees zero-length file, "root element is missing"

查看:97
本文介绍了XML反序列化器看到零长度文件,“根元素丢失”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个客户使用的程序反序列化了一个

XML文件,而在某些文件中,程序无法看到

的内容file - 将其视为零长度并报告缺少根元素 -

即使在记事本中文件看起来很正常。


有没有人见过这个?有线索吗?我无法在我的电脑上重现

。一般来说,当他们通过电子邮件将文件发送给我时,文件

完全正常。但有一次,电子邮件文件是零b长度。


谢谢!

解决方案

"MC < fo ************** @ www.ai.uga.edu.slash.mcwrote:


我有一对使用程序对XML文件进行反序列化的客户,以及某些文件,程序无法看到文件的内容

- 将其视为零长度和报告根元素是

缺失 - 即使在记事本中,文件看起来很正常。



可能是文件权限问题吗?


Eq。


2008年4月23日星期三06:41:52 -0700,MC

< fo ************** @ www.ai.uga。 edu.slash.mcwrote:


我有几个客户使用的程序将XML文件反序列化为
文件,程序无法看到文件的内容 - 将其视为零长度并报告根元素是

缺失 - 即使在记事本中文件看起来很正常。


有没有人见过这个?有线索吗?我无法在我的电脑上重现它。一般来说,当他们通过电子邮件将文件发送给我时,

文件到达完全正常。但有一次,电子邮件的

文件是零长度的。



如果用户能够实际显示一个零长度文件至少

一次,这让我怀疑其他文件那些不是
零长度实际上并不是正在读取的实际文件。这个

可能是因为用户提供了错误的文件,或者因为你有某种竞争条件,当你的文件是零长度时br />
程序试图读取它们,但是当用户稍后查看它们时却没有。


如何生成文件?


Pete


你的程序是否真的检查它是否要反序列化

格式良好的xml文档?并妥善处理这个预期的情况?我知道这可能看起来很明显......


- 彼得

为了取得成功,请使用这些工具武装自己你需要并学习如何使用

他们。


网站: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net

" MC"写道:


我有几个客户正在使用一个程序来反序列化一个

XML文件,在某些文件上,该程序未能看到

文件的内容 - 将其视为零长度并报告根元素缺失 -

即使在记事本中文件看起来很正常。


有没有人见过这个?有线索吗?我无法在我的电脑上重现

。一般来说,当他们通过电子邮件将文件发送给我时,文件

完全正常。但有一次,电子邮件文件是零b长度。


谢谢!


I have a couple of customers who are using a program that deserializes an
XML file, and on some files, the program fails to see the content of the
file -- treats it as zero length and reports "root element is missing" --
even though in Notepad the file looks normal.

Has anybody ever seen this? Any clues? I have not been able to reproduce
it on my computer. In general, when they e-mail me the files, the files
arrive perfectly normal. But on one occasion the e-mailed files were
zero-length.

Thanks!

解决方案

"MC" <fo**************@www.ai.uga.edu.slash.mcwrote:

I have a couple of customers who are using a program that deserializes
an XML file, and on some files, the program fails to see the content
of the file -- treats it as zero length and reports "root element is
missing" -- even though in Notepad the file looks normal.

Could it be a file permissions issue?

Eq.


On Wed, 23 Apr 2008 06:41:52 -0700, MC
<fo**************@www.ai.uga.edu.slash.mcwrote:

I have a couple of customers who are using a program that deserializes
an XML file, and on some files, the program fails to see the content of
the file -- treats it as zero length and reports "root element is
missing" -- even though in Notepad the file looks normal.

Has anybody ever seen this? Any clues? I have not been able to
reproduce it on my computer. In general, when they e-mail me the files,
the files arrive perfectly normal. But on one occasion the e-mailed
files were zero-length.

If the user was able to actually show you a zero-length file at least
once, that makes me suspicious that the other files that aren''t
zero-length are not in fact the actual file that was being read. This
could be because the user provided the wrong file, or because you''ve got
some sort of race condition in which the files were zero-length when your
program tried to read them, but not when the user looked at them later.

How are the files being generated?

Pete


Does your program actually check to see that it is about to deserialize a
well-formed xml document? And handle this expected condition properly? I
realize this may seem obvious...

-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net
"MC" wrote:

I have a couple of customers who are using a program that deserializes an
XML file, and on some files, the program fails to see the content of the
file -- treats it as zero length and reports "root element is missing" --
even though in Notepad the file looks normal.

Has anybody ever seen this? Any clues? I have not been able to reproduce
it on my computer. In general, when they e-mail me the files, the files
arrive perfectly normal. But on one occasion the e-mailed files were
zero-length.

Thanks!


这篇关于XML反序列化器看到零长度文件,“根元素丢失”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆