Android Cocos2d-x使用pugixml从URL的内容解析XML,我该怎么做?

Android Cocos2d-x使用pugixml从URL的内容解析XML,我该怎么做?,android,xml,url,cocos2d-x,Android,Xml,Url,Cocos2d X,这就是我一直在尝试的: pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file("Book.xml"); // need to change this std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("na

这就是我一直在尝试的:

pugi::xml_document doc;

pugi::xml_parse_result result = doc.load_file("Book.xml"); // need to change this

std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
编辑1:

显然这是不可能的。


那么我应该如何前进呢?

我使用cURL库从URL获取内容并将其保存到字符串中,如下所示:

CURL *curl;
CURLcode res;
std::string readBuffer;

curl = curl_easy_init();
if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "http:...");
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
}
然后我分析了字符串中包含的数据:

pugi::xml_document doc;
pugi::xml_parse_result result = doc.load(readBuffer.c_str());

Easy peasy:-)

我使用cURL库从URL获取内容并将其保存为字符串,如下所示:

CURL *curl;
CURLcode res;
std::string readBuffer;

curl = curl_easy_init();
if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "http:...");
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
}
然后我分析了字符串中包含的数据:

pugi::xml_document doc;
pugi::xml_parse_result result = doc.load(readBuffer.c_str());
简单豌豆:-)