我爱Aspx >> XML/XLST >> 在.NET Framework中轻松处理XML数据(五)我的XmlTextReadWriter类并没有从XmlReader或者XmlWriter类中继承。取而代之的是另外两个类,一个是基于只读流(stream)的操作类,另一个是基于只写流的操作类。XmlTextReadWriter类的方法用Reader对象读数据,写入到Writer对象。为了适应不同的需求,内部的Reader和Writer 对象分别通过只读的Reader和Writer属性公开。图十一列出了该类的一些方法:
Figure 11 XmlTextReadWriter Class Methods
Method
Description
AddAttributeChange
Caches all the information needed to perform a change on a node attribute. All the changes cached through this method are processed during a successive call to WriteAttributes.
Read
Simple wrapper around the internal reader's Read method.
WriteAttributes
Specialized version of the writer's WriteAttributes method, writes out all the attributes for the given node, taking into account all the changes cached through the AddAttributeChange method.
WriteEndDocument
Terminates the current document in the writer and closes both the reader and the writer.
WriteStartDocument
Prepares the internal writer to output the document and add a default comment text and the standard XML prolog.
这个新类有一个Read方法,它是对Reader的read方法的一个简单的封装。另外,它提供了WriterStartDocument和WriteEndDocument方法。它们分别初始化/释放(finalize)了内部Reader和writer对象,还处理所有I/O操作。在循环读节点的同时,我们就可以直接的修改节点。出于性能的原因,要修改属性必须先用AddAttributeChange方法声明。对一个节点的属性所作的所有修改都会存放在一个临时的表中,最后,通过调用WriteAttribute方法提交修改,清除临时表。
[1] [2] 下一页 【我对这篇文章有话说?】
在.NET Framework中轻松处理XML数..[05-06]
在.NET Framework中轻松处理XML数..[05-06]
在.NET Framework中轻松处理XML数..[05-06]
Visual Basic.NET带来的新方法(一..[05-05]
利用VC++获取异构型数据库库结构..[05-05]
抢救零磁道损坏的软盘数据[05-05]
浅谈DB2数据库的备份与恢复(下)[05-05]
浅谈DB2数据库的备份与恢复(上)[05-05]
Microsoft .NET Remoting:技术概..[05-05]
ASP.NET 入门的五个步骤[05-05]
在.NET Framework中轻松处理XML数..[05-06]
在.NET Framework中轻松处理XML数..[05-06]
在.NET Framework中轻松处理XML数..[05-06]
系统级C语言程序设计[05-05]
Visual Basic.NET带来的新方法(一..[05-05]
用VB设计能适应各种显示属性的界..[05-05]
关于VC中的DLL的编程[05-05]
解决BoundsChecker和VC打架的方法[05-05]
用VC++实现异形窗口.[05-05]
MFC消息响应机制分析[05-05]