Hi All,
I new to Xerces. I am trying to parse an XML file that has structure like
this :
<Messages>
<Send name="GO">This is text of GO message</Send>
<Receive name="COME">This is text of COME message></Receive>
</Messages>
The xml will be made of these Send and Receive Blocks. The problem is that i
not able to access the text values of the Send and Receive nodes i.e I am
not able to parse and fetch "This is text of GO message" and "This is text
of COME message". Please point out my mistake.
Here is my code :
m_ConfigFileParser->parse( xmlFile_.c_str() );
DOMDocument* xmlDoc = m_ConfigFileParser->getDocument();
DOMElement* elementRoot = xmlDoc->getDocumentElement();
if( !elementRoot )
{
return retVal;
}
DOMNodeList* children = elementRoot->getChildNodes();
const XMLSize_t nodeCount = children->getLength();
for( XMLSize_t xx = 0; xx < nodeCount; ++xx )
{
DOMNode* currentNode = children->item(xx);
if( currentNode->getNodeType() && currentNode->getNodeType() ==
DOMNode::ELEMENT_NODE )
{
DOMElement* currentElement = dynamic_cast<
xercesc::DOMElement* >( currentNode );
const XMLCh* xmlch_messageName =
currentElement->getAttribute(ATTR_Message);
const char* nodeVal =
XMLString::transcode(currentNode->getNodeValue());
printf("Node Text Value : : %s\n",nodeVal); //I WANT IT
TO PRINT NODE VALUE TEXT
}
else if(currentNode->getNodeType() &&
currentNode->getNodeType() == DOMNode::TEXT_NODE )
{
//TEXT_NODE ?. Anything to do here ?
}
}
Please CC me in the reply. Thanks !