QDomDocument

he QDomDocument
class represents an XML document.

QDomDocument类代表一个XML文件。

The QDomDocument class represents the entire XML
document. Conceptually, it is the root of the document tree, and provides the
primary access to the document’s data.

从概念上讲,它是文件树的根,并且提供了与文件数据的基本接口。

Since elements, text nodes,
comments, processing instructions, etc., cannot exist outside the context of a document,
the document class also contains the factory functions needed to create these
objects. The node objects created have an ownerDocument() function which associates them
with the document within whose context they were created. The DOM classes that
will be used most often are QDomNode,
QDomDocument,
QDomElement
and QDomText.

因为元素,文本节点,评论,处理指令等,都是一个文件的内容,此文件类也包含,为了创建这些对象的工厂函数。创建节点对象的是owerDocument()函数,这个函数连接了节点和包含这些节点的文件。DOM类中最常用的是QDomNode,QDomDocument,QDomElement,和QDomText.

The parsed XML is represented
internally by a tree of objects that can be accessed using the various QDom
classes. All QDom classes only reference objects in the internal tree.
The internal objects in the DOM tree will get deleted once the last QDom object
referencing them or the QDomDocument
itself is deleted.

解析后的XML的内部是一个对象树,可以通过这些QDom类读取到。所有的QDom类只参考了了内部树的对象。当最后的索引这些内置对象的QDom对象被删除或者QDomDocuent本身被删除的时候,Dom树中的这些内置对象挥别删除。

Creation of elements, text nodes,
etc. is done using the various factory functions provided in this class. Using
the default constructors of the QDom classes will only result in empty objects
that cannot be manipulated or inserted into the Document.

元素,文本节点等,是通过这个类提供的工厂函数来创建的。使用默认的QDom类的构造函数只能生成一个空的对象,无法使用也无法插入文件。

The QDomDocument class has several functions for
creating document data, for example, createElement(), createTextNode(),
createComment(),
createCDATASection(),
createProcessingInstruction(), createAttribute()
and createEntityReference().
Some of these functions have versions that support namespaces, i.e. createElementNS()
and createAttributeNS().
The createDocumentFragment()
function is used to hold parts of the document; this is useful for manipulating
for complex documents.

QDomDocument类有一些用来创建文件数据的函数,例如:createElement(),createTextNode(),createComment(),createCDATASection(),createProcessingInstruction(), createAttribute() 和 createEntityReference().其中一些有可以支持命名空间的版本,例如:createElementNS() 和createAttributeNS().createDocumentFragment()函数是用来保存文件的不同部分,当处理的复杂文件的时候,很实用。

The entire content of the document is set with setContent().
This function parses the string it is passed as an XML document and creates the
DOM tree that represents the document. The root element is available using documentElement().
The textual representation of the document can be obtained using toString().

整个文件的内容可以通过setContent()来设置。这个函数把传过来的字符串分析成XML文件,并创建DOM树来代表这个文件。使用documentElement()时可以使用根元素。文件的文本显示方式可以通过toString()获得。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值