음 Visual Studio 2010을 사용하여 C++에서 PugiXML을 사용하여 요소의 내용을 가져 왔지만 그 내용을 볼 때 값을 얻지 못하는 것이 있습니다. "<"은 값을 얻지 못하기 때문에 "<"이 요소를 닫지 않아도 "<"문자에 도달 할 때까지 내용을 가져옵니다. 태그를 무시하는 경우에도 닫는 태그에 도달 할 때까지 가져오고 내부 태그 내부의 텍스트 만 있으면됩니다.요소 (또는 태그)의 내용을 가져 오는 PugiXML C++
그리고 나는 또한 내가 요소를 가져올 경우, 예를 들어 외부 XML을 얻는 방법을 알고 싶습니다
pugi :: xpath_node_set 도구 = doc.select_nodes ("/ 메쉬/경계/B");
Attribute Href: http://www.google.com
Value: Link Till here
Name: a
: 여기
#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;
}
출력입니다 : 내가
이 내용 "링크 여기까지"가 될 것입니다 전체 콘텐츠를 위해 할 일을 여기 아래에 주어진 동일 내가 충분히 명확했으면 좋겠다. 미리 감사드립니다.