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

-- 
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **

Reply via email to