Recently I had an opportunity to use TinyXML to parse an XML. You can know more about it here: http://www.grinninglizard.com/tinyxml/
Download the libraries and compile it. Then you can start using the code. This way you can go about parsing the XML from one child element to the next.
//load the document you need to parse
TiXmlDocument document("Test.xml");
document.LoadFile();
//
// retrieve the root element
TiXmlElement* root = document.FirstChildElement( "personalInfo" );
//if the root element exists then only proceed to the next element
if ( root )
{
//darshan
TiXmlElement* child = document.FirstChildElement( "name" );
if(child)
{
//do some data manipulation here
//this will retrieve my name "darshan" here
const char* sDesc = root->GetText();
}
}
Leave a Reply