the QDomElement class represents one element in the DOM tree.
Elements have a tagName() and zero or more attributes associated with them. The tag name can be changed with setTagName().
Element attributes are represented by QDomAttr objects that can be queried using the attribute() and attributeNode() functions. You can set attributes with the setAttribute() and setAttributeNode() functions. Attributes can be removed with removeAttribute(). There are namespace-aware equivalents to these functions, i.e. setAttributeNS(), setAttributeNodeNS() and removeAttributeNS().
If you want to access the text of a node use text(), e.g.
这个类代表了元素在Dom树中。
元素有一个标签名,有0个或更多的属性联合它们。那个标签名可以改变用 setTagName().元素属性用QDomAttr 对象代表,查询可以用attribute() and attributeNode()查询属性和返回一个QDomAttr,
The text() function operates recursively to find the text (since not all elements contain text). If you want to find all the text in all of a node's children, iterate over the children looking for QDomText nodes, e.g.
Note that we attempt to convert each node to a text node and use text() rather than using firstChild().toText().data() or n.toText().data() directly on the node, because the node may not be a text element.
记录我们尝试用转变每个节点变为文本节点,用text()而不是用firstChild().toText().data().直接作用与node的节点。因为节点可能不是文本节点元素.
To browse the elements of a dom document use firstChildElement(), lastChildElement(), nextSiblingElement() and previousSiblingElement(). For example, to iterate over all child elements called "entry" in a root element called "database", you can use: