Axel Weiß wrote:
dara wrote:
Hi all,
what is the best way to get and process a list of attributes from a
domNode/elementNode ?
i can find references for the SAX implementation, but not for DOM.
any pointers appreciated.
Hi dara,
I usually do the following to traverse attributes:
DOMNode *node; // the node we want to get the attrs of
// this really should be a DOMElement
DOMNamedNodeMap *map = node->getAttributes();
int i, len = map ? map->getLength() : 0;
for (i=0; i<len; ++i){
DOMNode *attr = map->item(i);
// here you have every attribute as a DOMNode,
// and can read the attribute name / value
// by attr->getNodeName() / attr->getNodeValue()
}
If you know the attribute name of interest a proiri, it is better to use
the DOMElement methods getAttribute or getAttributeNode.
I hope it helps,
Axel
Hi Axel,
That will do nicely, i won't know the names of the attributes that are
there.
Go raibh míle maith agat,
Dara