tags:

views:

68

answers:

1

hello
is it possible to get all attributes for a particular node in pyqt ? for example .. consider for following node:
< asset Name="3dAsset" ID="5"/>
i want to retrieve the ("Name" and "ID") strings
is it possible?

thanks in advance

+1  A: 

You can retrieve the particular value of the attribute using the function,

QString QDomElement::attribute ( const QString & name, const QString & defValue = QString() ) const

To get all the attributes use,

QDomNamedNodeMap QDomElement::attributes () const

and you have to traverse through the DomNamedNodeMap and get the value of each of the attributes. Hope it helps.

Edit : Try this one.

With the QDomNamedNodeMap you are having give,

QDomNode QDomNamedNodeMap::item ( int index ) const

which will return a QDomNode for the particular attribute. Then give,

QDomAttr QDomNode::toAttr () const

With the QDomAttr obtained give,

QString name () const

which will return the name of the attribute. Hope it helps.

liaK
it returns a DomNamedNodeMap and i couldn't see how it can help me with retrieving the strings ( "Name" ) and ("ID") , i don't want the values of those attributes. i just want the attribute name .
Moayyad Yaghi