Sign in to follow this  
medhassu

Extracting text data from XML string using tinyxml

Recommended Posts

Hai Associates, I have been working on how to retrieve the text data from XML form using tinyxml parser since 2 days.From the following XML string i have to retrieve the data. <rx-event> <topic>Mgmt</topic> <subtopic>645268923afce</subtopic> <context>PubSubComm-3</context> <params> <rx-status>ok</rx-status> <column1>Hello</column1> <column2>412</column2> <column3>Welcome to</column3> <column4>India</column4> </params> </rx-event> I should have to get the each field(i.e Mgmt,Hello,412 etc)in to seperate variables.So kidly give me some suggestions to write the APIs to extract thedata. I am using tinyxml_2_3_3. Some body has given the solution to print all contents of XML string. Thank you very much. But my reqquirement is i have to copy some selected values in to the buffer which should be retuned to the calling function. Please give some solution to it . [Edited by - medhassu on May 23, 2006 6:16:23 AM]

Share this post


Link to post
Share on other sites
Something like this



void Load()
{
TiXmlDocument Doc;
Doc.Parse(your_string);

RecurseTree(&Doc);
}

void RecurseTree(TiXmlNode *pNode)
{
printf("%s\n", pNode->Value());
TiXmlNode *Child = pNode->FirstChild();
for(; Child; Child = pNode->IterateChildren(Child))
RecurseTree(Child);
}


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this