XMLReader问题 [英] XMLReader Problem

查看:109
本文介绍了XMLReader问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在转向VB.NET,我正在尝试将记录集加载到XMLReader中并循环记录。当我使用.ReadElementString()方法来获取下一个''记录'时,如果它已经到达最后一条记录(eof),它将失败,并且当阅读器关闭时无效尝试阅读。在错误发生之前,它似乎无法找到它(Readstate在失败之前是交互式的并且EOF是假的。)


这个有限的信息是否足以让任何人分辨我哪里出错了? (目前我正处于早期阶段,我有错误的数字= 5然后err.clear哪个有点废话所以......)


谢谢,


Ben。

Hi,

I''m just moving to VB.NET and I''m trying to load a recordset intoan XMLReader and loop through the records. When I use the.ReadElementString() method to get the next ''record'' if it hasreached the last record (eof) it fails with "Invalid attempt toread when reader is closed". It doesn''t seem capable of findingthis out until the error has occured though (Readstate isinteractive prior to the failure and EOF is false.)

Is this limited information enough for anyone to tell me whereI''m going wrong ? (currently as I''m in the early stages I haveif err.number = 5 then err.clear which is a bit crap so ...)

Thanks,

Ben.

推荐答案

你是如何在阅读器中循环的?


你是否通过调用Read方法检查返回值?

虽然reader.Read()


''做的事情。 ..


结束时


-

HTH

Christoph Schittko [ MVP,XmlInsider]

软件架构师,.NET Mentor

" Ben" < GR ********* @ hotmail.com>在消息中写道

新闻:Os ************* @ TK2MSFTNGP11.phx.gbl ...




我正在转向VB.NET,我正在尝试将记录集加载到

XMLReader中并循环记录。当我使用.ReadElementString()

方法来获取下一个''记录'时,如果它已达到最后一个记录(eof)它

失败并且无效试图阅读读者何时关闭。虽然错误已经发生,但似乎没有能够找到它(Readstate是

在失败之前互动并且EOF是假的。)


这个有限的信息是否足以让任何人告诉我我要去哪里

错了? (目前我正处于早期阶段,如果err.number = 5那么

err.clear这有点废话所以......)


谢谢,


Ben。
How are you looping through the reader?

Are you checking the return value from the call to the Read method?

While reader.Read()

'' do stuff ...

End While

--
HTH
Christoph Schittko [MVP, XmlInsider]
Software Architect, .NET Mentor
"Ben" <gr*********@hotmail.com> wrote in message
news:Os*************@TK2MSFTNGP11.phx.gbl...
Hi,

I''m just moving to VB.NET and I''m trying to load a recordset into an
XMLReader and loop through the records. When I use the .ReadElementString()
method to get the next ''record'' if it has reached the last record (eof) it
fails with "Invalid attempt to read when reader is closed". It doesn''t seem
capable of finding this out until the error has occured though (Readstate is
interactive prior to the failure and EOF is false.)

Is this limited information enough for anyone to tell me where I''m going
wrong ? (currently as I''m in the early stages I have if err.number = 5 then
err.clear which is a bit crap so ...)

Thanks,

Ben.


嗨Ben,

即使我面对的是同样的问题。我得到三条没有Root的记录

元素。我能够在结束后读取值结果它说

相同的错误,例如读取器关闭时读取无效的尝试。任何事情

我们做错了。如果你找到答案,请回复我。


谢谢

Anandraj.A。


" Christoph Schittko [MVP]" < CH ******************** @ austin.rr.com>写在

消息新闻:#v ************** @ tk2msftngp13.phx.gbl ...
Hi Ben,
Even I am facing the Same Problem. I am getting three records without Root
Element. I am able to read the values to the End After the End It saying the
same error like "Invalid attempt to read when reader is closed". Any thing
we are doing wrong. Please reply me if you have found out the answer.

Thanks
Anandraj.A.

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:#v**************@tk2msftngp13.phx.gbl...
你是如何循环的通过读者?

你是否通过调用Read方法检查返回值?

虽然读者阅读()

''做什么...

结束时间

-
HTH
Christoph Schittko [MVP,XmlInsider]
软件架构师,.NET导师
本 < GR ********* @ hotmail.com>在消息中写道
新闻:Os ************* @ TK2MSFTNGP11.phx.gbl ...
你好,

我是刚刚转到VB.NET,我正在尝试将记录集加载到XMLReader中并循环记录。当我使用
..ReadElementString()方法来获取下一个''记录'时,如果它已经到达最后一个记录(eof),那么
将失败并且读取器关闭时无效尝试读取 ;。在发生错误之前,看起来没有
似乎能够找到它(Readstate
在失败之前是交互式的并且EOF是假的。)

这是有限的吗?信息足以让任何人告诉我我要去哪里错了? (目前我正处于早期阶段,如果err.number = 5
那么err.clear哪个有点废话所以......)

谢谢,
本。
How are you looping through the reader?

Are you checking the return value from the call to the Read method?

While reader.Read()

'' do stuff ...

End While

--
HTH
Christoph Schittko [MVP, XmlInsider]
Software Architect, .NET Mentor
"Ben" <gr*********@hotmail.com> wrote in message
news:Os*************@TK2MSFTNGP11.phx.gbl...
Hi,

I''m just moving to VB.NET and I''m trying to load a recordset into an
XMLReader and loop through the records. When I use the ..ReadElementString() method to get the next ''record'' if it has reached the last record (eof) it
fails with "Invalid attempt to read when reader is closed". It doesn''t seem capable of finding this out until the error has occured though (Readstate is interactive prior to the failure and EOF is false.)

Is this limited information enough for anyone to tell me where I''m going
wrong ? (currently as I''m in the early stages I have if err.number = 5 then err.clear which is a bit crap so ...)

Thanks,

Ben.



Anandraj写道:
Anandraj wrote:
即使我面对的是同样的问题。我收到三条没有Root
元素的记录。我能够将值读到结束后的结尾它表示
相同的错误,例如读取器关闭时无效的读取尝试。任何事情
我们做错了。如果你找到了答案,请回复我。
Even I am facing the Same Problem. I am getting three records without Root
Element. I am able to read the values to the End After the End It saying the
same error like "Invalid attempt to read when reader is closed". Any thing
we are doing wrong. Please reply me if you have found out the answer.




目前尚不清楚你是什么意思。向我们展示一些代码。

基本上你不负责调用XmlReader的方法

没有更多的输入要读。

-

Oleg Tkachenko
http:/ /www.tkachenko.com/blog

Multiconn Technologies,Israel



It''s not clear what do you mean. Show us some code.
Basically it''s your responsibility not to call XmlReader''s methods when
there is no more input to read.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel


这篇关于XMLReader问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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