Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Please help.
- struct myRec
- {
- std::string one;
- std::string two;
- std::string three;
- std::string four;
- std::string five;
- std::string six;
- };
- uint32_t count = 0;
- XMLDocument doc;
- doc.LoadFile(pFilename);
- XMLElement* parent = doc.FirstChildElement("a");
- XMLElement* child = parent->FirstChildElement("b");
- XMLElement* e = child->FirstChildElement("c");
- for (e = child->FirstChildElement("c"); e; e = e->NextSiblingElement("c"))
- {
- count++;
- }
- std::cout << "n""Count = " << count << std::endl;
- recs = (myRec *)malloc(6 *count * sizeof(myRec));
- XMLElement *row = child->FirstChildElement();
- if (count > 0)
- {
- --count;
- count = (count < 0) ? 0 : count;
- for (uint32_t i = 0; i <= count; i++)
- {
- while (row != NULL)
- {
- std::string six;
- six = row->Attribute("ID");
- recs[i].six = six;
- XMLElement *col = row->FirstChildElement();
- while (col != NULL)
- {
- std::string sKey;
- std::string sVal;
- char *sTemp1 = (char *)col->Value();
- if (sTemp1 != NULL) {
- sKey = static_cast<std::string>(sTemp1);
- }
- else {
- sKey = "";
- }
- char *sTemp2 = (char *)col->GetText();
- if (sTemp2 != NULL) {
- sVal = static_cast<std::string>(sTemp2);
- }
- else {
- sVal = "";
- }
- if (sKey == "one") {
- recs[i].one = sVal;
- }
- if (sKey == "two") {
- recs[i].two = sVal;
- }
- if (sKey == "three") {
- recs[i].three = sVal;
- }
- if (sKey == "four") {
- recs[i].four = sVal;
- }
- if (sKey == "five") {
- recs[i].five = sVal;
- }
- col = col->NextSiblingElement();
- }// end while col
- std::cout << "n""one = " << recs[i].one << "n"" two= " << recs[i].two << "n""three = " << recs[i].three << "n""four = " << recs[i].four << "n""five = " << recs[i].five << "n""six = " << recs[i].six << std::endl;
- row = row->NextSiblingElement();
- }// end while row
- }
- }
- else
- {
- std::cout << "Failed to find value, please check XML! n" << std::endl;
- }
- return *recs;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement