المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : XML Parsing using Tiny XML



C++ Programming
04-29-2011, 06:30 AM
Hi!
I've to parse an XML File using Tiny XML. My XML file contents are:

</span span class="code-SummaryComment"version/spanspan class="code-keyword"="/spanspan class="code-keyword"1.0"/spanspan class="code-SummaryComment"?/spanspan class="code-SummaryComment">T5jkbec7i2f410mLogin,Reset,Exit
I've to pass "TicketID" and get the result as "T5jkbec7i2f410m". Also I've to pass "Form1Buttons" and get "Login,Reset,Exit" as result.

I've used the following code:

const char* common::Parse_XML_Document(char* filename, char* tagname){ TiXmlDocument * tiDoc = new TiXmlDocument(filename); TiXmlElement * tiElement = new TiXmlElement(tagname); const char * value = new char[1024]; //TiXmlAttribute * tiAttribute = new TiXmlElement(tagname); if(tiDoc->LoadFile()) { value = tiElement->GetText(); } return value;}

But value contains only a BadPtr. How to pass the XML file name and the tag name and retrieve the value of that tag?