C++でVisual Studio 2010を使用して要素の内容を取得するPugiXMLを使用していますが、要素の内容を取得するためにPugiXMLが停止することがあります"<"は値を取得しないので、 "<"が要素を閉じていなくても "<"文字に達するまでコンテンツを取得します。タグを無視しても終了タグに到達するまで取得したいが、内側のタグの中のテキストは少なくとも、それを取得したい。要素(またはタグ)の内容を取得するPugiXML C++
そして私はまた、私は要素にフェッチ場合例えば外部XMLを取得する方法を知っていただきたいと思い
プーギー:: 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
私は十分にはっきりしていたと思う。 ありがとうございました