Last active
May 11, 2017 23:57
-
-
Save Bueddl/95c9e039e2499a704d7cdcb67b5ce955 to your computer and use it in GitHub Desktop.
Parsingtest for XmlRpc using tinyxml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <tinyxml.h> | |
int main() | |
{ | |
TiXmlDocument doc("../toffe.xml"); | |
if(!doc.LoadFile()) | |
{ | |
std::cout << "Could not load XML File." << std::endl; | |
return 1; | |
} | |
TiXmlHandle hDoc(&doc); | |
TiXmlElement *methodCallNode = doc.FirstChildElement("methodCall"); | |
assert(methodCallNode); | |
std::cout << "methodName: " | |
<< methodCallNode->FirstChildElement("methodName")->GetText() | |
<< std::endl; | |
TiXmlElement *paramsNode = methodCallNode->FirstChildElement("params"); | |
assert(paramsNode); | |
for (TiXmlElement *paramNode = paramsNode->FirstChildElement(); | |
; | |
paramNode = paramNode->NextSiblingElement()) | |
{ | |
assert(paramNode); | |
TiXmlElement *valueNode = paramNode->FirstChildElement("value"); | |
assert(valueNode); | |
TiXmlElement *structNode = valueNode->FirstChildElement(); | |
assert(structNode); | |
if (structNode->ValueStr() == "struct") | |
{ | |
for (TiXmlElement *structMemberNode = structNode->FirstChildElement();; | |
structMemberNode = structMemberNode->NextSiblingElement()) { | |
assert(structMemberNode); | |
TiXmlElement *memberNameNode = structMemberNode->FirstChildElement("name"); | |
assert(memberNameNode); | |
TiXmlElement *memberValueNode = structMemberNode->FirstChildElement("value"); | |
assert(memberValueNode); | |
TiXmlElement *memberValueTypeNode = memberValueNode->FirstChildElement(); | |
assert(memberValueTypeNode); | |
std::cout << memberNameNode->GetText() | |
<< ": " | |
<< memberValueTypeNode->GetText() | |
<< " (" << memberValueTypeNode->ValueStr() << ")" | |
<< std::endl; | |
if (structMemberNode == structNode->LastChild()) | |
break; | |
} | |
} else if (structNode->ValueStr() != "array") | |
{ | |
std::cout << structNode->GetText() | |
<< " (" << structNode->ValueStr() << ")" | |
<< std::endl; | |
} | |
if (paramNode == paramsNode->LastChild()) | |
break; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment