如何在作为参数传递的XmlDocument上使用XmlReader [英] How do I use XmlReader on an XmlDocument passed as a parameter

查看:62
本文介绍了如何在作为参数传递的XmlDocument上使用XmlReader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有XmlReader示例都假定正在从

文件中读取XmlDocument。但是,我想将它与作为

方法参数传递的XmlDocument一起使用,但我不确定如何。


有什么建议吗?

All of the XmlReader examples assume that the XmlDocument is being read from
a file. However, I would like to use it with an XmlDocument passed as a
method parameter, but am not sure how.

Any suggestions?

推荐答案




Thirsty Traveler写道:


Thirsty Traveler wrote:
所有XmlReader示例假设正在从文件中读取XmlDocument。但是,我想将它与作为
方法参数传递的XmlDocument一起使用,但我不确定如何。
All of the XmlReader examples assume that the XmlDocument is being read from
a file. However, I would like to use it with an XmlDocument passed as a
method parameter, but am not sure how.




XmlReader只是一个快速,仅向前非缓存方式来解析XML。如果你有
有一个XmlDocument实例,那么XML已经被解析为一个

可导航树模型,你可以在其上进行DOM和XPath操作。所以我

一旦你有了一个

的XmlDocument,我不确定为什么你认为你需要一个XmlReader。如果您仍想使用XmlReader API,那么

就有XmlNodeReader,例如

XmlReader reader = new XmlNodeReader(xmlDocumentInstanceOrOtherXMLNode);


-


Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


你究竟想做什么?阅读XmlDocument?如果你已经有了一个XmlDocument,那么XPath / XQuery(.SelectNodes(),. SelectSingleNode())和

对象模型(.GetAttribute()等)这似乎是自然的选择 - 因为它已经太晚了,无法从XmlReader的效率中加强......再加上

更容易做对!除非您需要将相应的

xml-reader传递给另一种方法?


Marc
What exactly are you trying to do? Read the XmlDocument? If you already have
an XmlDocument, then XPath/XQuery (.SelectNodes(), .SelectSingleNode()) and
the object-model (.GetAttribute() etc) would seem the natural choice - as it
is already too late to beefit from the efficiencies of XmlReader... plus it
is a lot easier to get right! Unless you need to pass a corresponding
xml-reader to another method?

Marc


我有一个XML文档,它从一个Web服务传递,包含1到

许多交易请求到我们的大型机。我需要将此

XML文档中的值映射到大型机事务并调用它一次或多次

(XML文档中的每个事务一次)。我认为XmlReader

会更快达到这个目的。


" Marc Gravell" <毫安********** @ gmail.com>在消息中写道

新闻:呃************** @ TK2MSFTNGP02.phx.gbl ...
I have an XML document that is passed from a web service that contains 1 to
many transaction requests to our mainframe. I need to map the values in this
XML document to the mainframe transaction and call it one or more times
(once for each transaction in the XML document). I was thinking XmlReader
would be faster for this purpose.

"Marc Gravell" <ma**********@gmail.com> wrote in message
news:uh**************@TK2MSFTNGP02.phx.gbl...
你究竟在尝试什么?去做?阅读XmlDocument?如果你已经有了一个XmlDocument,那么XPath / XQuery(.SelectNodes(),
.SelectSingleNode())和对象模型(.GetAttribute()等)似乎是自然的选择 - 因为从XmlReader的效率来加强已经为时已晚......加上它变得更加容易!除非
你需要将相应的xml-reader传递给另一种方法?

Marc
What exactly are you trying to do? Read the XmlDocument? If you already
have an XmlDocument, then XPath/XQuery (.SelectNodes(),
.SelectSingleNode()) and the object-model (.GetAttribute() etc) would seem
the natural choice - as it is already too late to beefit from the
efficiencies of XmlReader... plus it is a lot easier to get right! Unless
you need to pass a corresponding xml-reader to another method?

Marc



这篇关于如何在作为参数传递的XmlDocument上使用XmlReader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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