需要解析xml的多个属性,找到下载资源中的test文件,可以使用Next()指向当前下个XmlAttribure。
#include “reconvertXml.h”
using namespace std;
using namespace tinyxml2;
int handleSipMessage()
{
string aa = “<?xml version=\"1.0\" encoding=\"UTF-8\"?><SIP_XML EventType=“Request_Resource” a=“3”>
<Item Code=“地址” FromIndex=“期望返回的起始记录数” ToIndex=“期望返回的结束记录数”/></SIP_XML>”;
XMLDocument doc;
doc.Parse(aa.c_str());
XMLElement* SIPXML = doc.RootElement();
const XMLAttribute * eventTypeAttr = SIPXML->FirstAttribute();
string eventType = eventTypeAttr->Value();
cout<<eventType<<endl;
if(eventType == “Request_Resource”)
{
cout<<“request_resource”<<endl;
XMLElement* item = SIPXML->FirstChildElement(“Item”);
const XMLAttribute* a = item->FirstAttribute();
string code = a->Value();
cout<<code<<endl;
a= a->Next();
string fromIndex = a->Value();
cout<<fromIndex<<endl;
a= a->Next();
string toIndex = a->Value();
cout<<toIndex<<endl;
}
return 0;
}