SHARE
TWEET

Untitled

a guest Jul 18th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Please help.
  2.      
  3. struct myRec
  4. {
  5. std::string one;
  6. std::string two;
  7. std::string three;
  8. std::string four;
  9. std::string five;
  10. std::string six;
  11. };
  12.  
  13. uint32_t count = 0;
  14.  
  15. XMLDocument doc;
  16. doc.LoadFile(pFilename);
  17. XMLElement* parent = doc.FirstChildElement("a");
  18. XMLElement* child = parent->FirstChildElement("b");
  19. XMLElement* e = child->FirstChildElement("c");
  20.  
  21. for (e = child->FirstChildElement("c"); e; e = e->NextSiblingElement("c"))
  22. {
  23.     count++;
  24. }
  25.  
  26. std::cout << "n""Count = " << count << std::endl;
  27.  
  28. recs = (myRec *)malloc(6 *count * sizeof(myRec));
  29.  
  30. XMLElement *row = child->FirstChildElement();
  31. if (count > 0)
  32. {
  33.     --count;
  34.     count = (count < 0) ? 0 : count;
  35.     for (uint32_t i = 0; i <= count; i++)
  36.     {
  37.         while (row != NULL)
  38.         {
  39.             std::string six;
  40.             six = row->Attribute("ID");
  41.             recs[i].six = six;
  42.  
  43.             XMLElement *col = row->FirstChildElement();
  44.             while (col != NULL)
  45.             {
  46.                 std::string sKey;
  47.                 std::string sVal;
  48.                 char *sTemp1 = (char *)col->Value();
  49.                 if (sTemp1 != NULL) {
  50.                     sKey = static_cast<std::string>(sTemp1);
  51.                 }
  52.                 else {
  53.                     sKey = "";
  54.                 }
  55.                 char *sTemp2 = (char *)col->GetText();
  56.                 if (sTemp2 != NULL) {
  57.                     sVal = static_cast<std::string>(sTemp2);
  58.                 }
  59.                 else {
  60.                     sVal = "";
  61.                 }
  62.                 if (sKey == "one") {
  63.                     recs[i].one = sVal;
  64.                 }
  65.                 if (sKey == "two") {
  66.                     recs[i].two = sVal;
  67.                 }
  68.                 if (sKey == "three") {
  69.                     recs[i].three = sVal;
  70.                 }
  71.                 if (sKey == "four") {
  72.                     recs[i].four = sVal;
  73.                 }
  74.                 if (sKey == "five") {
  75.                     recs[i].five = sVal;
  76.                 }
  77.                 col = col->NextSiblingElement();
  78.             }// end while col
  79.             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;
  80.             row = row->NextSiblingElement();
  81.         }// end while row
  82.     }
  83. }
  84. else
  85. {
  86.     std::cout << "Failed to find value, please check XML! n" << std::endl;
  87. }
  88. return *recs;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top