Xerces XML: Need to access element value
Can anyone assist: I'm using the Xerces/C++ libraries and I'm trying to access/print out the element value for the elements within my XML file. In the code below, I have no problem printing out the element names, attribute names and values, but do not know how to access the element values.
code:
Code:
void SAX2CountHandlers::startElement(const XMLCh* const uri
, const XMLCh* const localname
, const XMLCh* const qname
, const Attributes& attrs)
{
//local variables
char* element_name = XMLString::transcode(qname);
char * theElementValue = XMLString::transcode( );
unsigned int n;
if( element_name != 0 )
{
//print to console/screen
XERCES_STD_QUALIFIER cerr << "Element Name: "<< element_name << "\n" <<XERCES_STD_QUALIFIER endl;
for( n = 0 ; n < attrs.getLength() && n < 2 ; n++ )
{
char* attrName = XMLString::transcode(attrs.getQName(n) );
char* attrValue = XMLString::transcode(attrs.getValue(n) );
//print to console/screen
XERCES_STD_QUALIFIER cerr << "Attribute Name: "<< attrName << " Attribute Value: " << attrValue<<XERCES_STD_QUALIFIER endl;
XMLString::release( &attrName );
XMLString::release( &attrValue );
}//end forLoop
}//end if
XMLString::release(&element_name);
.
.
.