[QtXml module]
该QDomAttr类表示的一个属性QDomElement。More…
继承QDomNode。
Methods
__init__ (self)
__init__ (self, QDomAttr x)
QString name (self)
QDomNode.NodeType nodeType (self)
QDomElement ownerElement (self)
setValue (self, QString)
bool specified (self)
QString value (self)
Detailed Description
该QDomAttr类表示的一个属性QDomElement。
例如,下面的XML片段的产生与没有孩子,但两个属性的元素:
<link href="http://qt.nokia.com" color="red" />
您可以访问这样的代码元素的属性:
[QDomElement](docs_qdomelement.html) e = //...
//...
QDomAttr a = e.attributeNode("href");
cout << a.value() << endl; // prints "http://qt.nokia.com"
a.setValue("http://qt.nokia.com/doc"); // change the node's attribute
QDomAttr a2 = e.attributeNode("href");
cout << a2.value() << endl; // prints "http://qt.nokia.com/doc"
这个例子还表明,改变从一个元件接收的属性改变元素的属性。如果您不希望更改元素的属性的值必须使用cloneNode( )来获得属性的独立副本。
QDomAttr可以返回name()和value一个属性() 。一个属性的值设置setValue( ) 。如果specified( )返回True值被设置setValue( ) 。该节点将该属性附加到(如果有的话)是由返回ownerElement( ) 。
关于文档对象模型有进一步的信息http://www.w3.org/TR/REC-DOM-Level-1/和http://www.w3.org/TR/DOM-Level-2-Core/。对于更一般介绍的DOM实现的见QDomDocument文档。
Method Documentation
QDomAttr.__init__ (self)
构造一个空属性。
QDomAttr.__init__ (self, QDomAttr x)
构造的副本x。
副本的数据是共享的(浅拷贝) :修改一个节点也将改变其他。如果你想使一个深拷贝,使用cloneNode( ) 。
QString QDomAttr.name (self)
返回属性的名称。
QDomNode.NodeType QDomAttr.nodeType (self)
QDomElement QDomAttr.ownerElement (self)
返回此属性附加到或元素节点null node如果这个属性没有连接到任何元素。
QDomAttr.setValue (self, QString)
设置该属性的值v。
See also value( ) 。
bool QDomAttr.specified (self)
返回True如果该属性已设置用户使用setValue( ) 。如果未指定或设置该值,则返回False 。
See also setValue( ) 。
QString QDomAttr.value (self)
如果未指定该属性返回属性或空字符串的值。