嗯,我使用C中PugiXML ++使用Visual Studio 2010来获得元素的含量,但事情是,它停下来所获得的价值是看到了当“<”,所以它没有得到的价值,它只是直到它到达即使“<”不打烊其元素的“<”角色获得的内容。我希望它得到它,直到它达到它的结束标记,即使它忽略了标记,但只有内部标记内部的文本,至少。PugiXML C++元素(或标签)的获取内容
而且我也想知道如何获得例如外XML,如果我取元素
pugi :: xpath_node_set工具= doc.select_nodes(“/网/边界/ B”); 我该怎么办,以获得其全部内容将是“链接到这里”
此内容在这里给出上下一致:
#include "pugixml.hpp"
#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int main//21
() {
string source = "<mesh name='sphere'><bounds><b id='hey'> <a DeriveCaptionFrom='lastparam' name='testx' href='http://www.google.com'>Link Till here<b>it will stop here and ignore the rest</b> text</a></b> 0 1 1</bounds></mesh>";
int from_string;
from_string = 1;
pugi::xml_document doc;
pugi::xml_parse_result result;
string filename = "xgconsole.xml";
result = doc.load_buffer(source.c_str(), source.size());
/* result = doc.load_file(filename.c_str());
if(!result){
cout << "File " << filename.c_str() << " couldn't be found" << endl;
_getch();
return 0;
} */
pugi::xpath_node_set tools = doc.select_nodes("/mesh/bounds/b/a[@href='http://www.google.com' and @DeriveCaptionFrom='lastparam']");
for (pugi::xpath_node_set::const_iterator it = tools.begin(); it != tools.end(); ++it) {
pugi::xpath_node node = *it;
std::cout << "Attribute Href: " << node.node().attribute("href").value() << endl;
std::cout << "Value: " << node.node().child_value() << endl;
std::cout << "Name: " << node.node().name() << endl;
}
_getch();
return 0;
}
这里是输出:
Attribute Href: http://www.google.com
Value: Link Till here
Name: a
我希望我是再清楚不过, 在此先感谢