Jump to content
  • Advertisement
Sign in to follow this  
medhassu

Mapping the Values in to Buffer

This topic is 4438 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hai Associates, I have been working on the retrieving text data from the XML string. I am using tinyxml_2_3_3 parser.I have used the following APIs to get the data 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); } By using it i am able to print the contents of the string. But i should have to copy the values from pNode->Value() in to a single buffer which should be returned to calling function. The following is my XML string. <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 have to copy all values in to a buffer from which i should be able to retrieve all the values one by one later. Please suggest any solution for it. I am working in C++ platform. [Edited by - medhassu on May 25, 2006 3:29:58 AM]

Share this post


Link to post
Share on other sites
Advertisement
You need to change your recursion to detect the elements that you care about:

// pseudocode
void RecurseTree(TiXmlNode *pNode, std::vector<std::string> *stuff_you_care_about)
{
if (pNode->Type()==TiXmlNode::ELEMENT)
{
ParseElement(pNode->ToElement(), stuff_you_care_about);
}

TiXmlNode *Child = pNode->FirstChild();
for(; Child; Child = pNode->IterateChildren(Child))
RecurseTree(Child, stuff_you_care_about);
}

ParseElement(TiXmlElement *pElement, std::vector<std::string> *stuff_you_care_about)
{
if (pElement->Value()==value_tag_i_care_about)
{
stuff_you_care_about(pElement->FirstChild()->AsText()->Value());
}
}


Or something like that

Hope this helps

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!