Wait a minute.. I did answer the wrong question here, didn't I? The method getAttribute is a member of the DOMElement.
http://xml.apache.org/xerces-c/apiDocs/classDOMElement.html virtual const XMLCh * getAttribute (const XMLCh *name) const=0 Retrieves an attribute value by name. But I found the foulup in your code. printAttributeValue(typeChild->getFirstChild(), "min"); This returns the first child of ElementLength. Which according to your example have no childs. And by the way, getFirstChild() returns a DOMNode* which doesn't have the getAttribute method. You need to cast it to an DOMElement*, see below. // Erik -----Original Message----- From: Erik Rydgren [mailto:[EMAIL PROTECTED] Sent: den 24 mars 2003 14:02 To: [EMAIL PROTECTED] Subject: RE: parsing DOM tree: How to get attribute values Oh THAT! :) Just cast your DOMNode* to a DOMElement*. If you are paranoid then you can do a check that the node really is an element. DOMElement poElement = NULL; if (poNode->getType() == ELEMENT_NODE) poElement = static_cast<DOMElement*>(poNode); Regards Erik Rydgren Mandarinen systems AB Sweden -----Original Message----- From: Andreas B. Thun [mailto:[EMAIL PROTECTED] Sent: den 24 mars 2003 12:10 To: [EMAIL PROTECTED] Subject: Re: parsing DOM tree: How to get attribute values Thx, Erik and Paul but ... how can I get the element? I selected the right node (ElementLength) but I cannot compile this because getAttribute is not a member of the DOMElement class. I tried getAttributeNode, but it doesn�t work, either... // ------------------------------------------------------------------------- -- // printAttributeValue // ------------------------------------------------------------------------- -- static void printAttributeValue(DOMNode *node, char *attributeName) { // doesn�t compile const char* pzMin = XMLString::transcode(node->getAttribute(attributeName)); return; } // printAttributeValue() main(): ... // scan children of <Type> for (typeChild = node->getFirstChild(); typeChild != 0; typeChild = typeChild->getNextSibling()) { if (typeChild->getNodeType() == DOMNode::ELEMENT_NODE) { // ElementLength if (XMLString::compareString(typeChild->getNodeName(), typeElementLengthStr) == 0) { printNodeName(typeChild); // prints "ElementLength" -> ok printAttributeValue(typeChild->getFirstChild(), "min"); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
