you may want to take a look at the new DomCount.cpp file. This comes with the samples. I believe it has an example of accessing and using attributes.
-Vinayak > -----Original Message----- > From: Andreas B. Thun [mailto:[EMAIL PROTECTED] > Sent: Monday, March 24, 2003 10:26 AM > To: [EMAIL PROTECTED] > Subject: Re: parsing DOM tree: How to get attribute values ( I don�t > like mondays) > > > > printAttributeValue(typeChild->getFirstChild(), "min"); > > Thx. That helped a lot. In my opinion the first child of ElementLength > was the attribute min. > > > 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. > > You will not believe it. It just does not compile. See was g++ issues: > > > // > -------------------------------------------------------------- > ------------- > // printAttributeValue > // > -------------------------------------------------------------- > ------------- > static void printAttributeValue(DOMNode *node, char *attributeName) > { > const XMLCh *attrName; > > DOMElement *nodeElement = NULL; // added * here! > > if (node) > { > nodeElement = static_cast(DOMElement *) (node); // > what is the problem? > attrName = > nodeElement->getAttribute(XMLString::transcode(attributeName)); > } > > return; > > } // printAttributeValue() > > > > DomParse.cpp: In function `void > printAttributeValue(xercesc_2_2::DOMNode*, > char*)': > DomParse.cpp:32: parse error before `DOMElement' > make: *** [DomParse.o] Error 1 > > > > --------------------------------------------------------------------- > 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]
