私はRapidXmlをC++プログラムで使用しています。まあまあ問題ないそれは動作します。私が代わりに変数値のポインタを使用する必要がありますなぜ私はちょうどあなたがRapidXmlのwikiページに見てみる場合は、いくつかの例が提供され、これはRapidXml開発者によって提供される一つである... を理解していない:RapidXmlメモリ割り当てを理解しようとしています
#include <iostream>
#include <string>
#include "rapidxml-1.13/rapidxml.hpp"
#include "rapidxml-1.13/rapidxml_print.hpp"
int main(int argc, char** argv);
int main(int argc, char** argv) {
using namespace rapidxml;
xml_document<> doc;
// xml declaration
xml_node<>* decl = doc.allocate_node(node_declaration);
decl->append_attribute(doc.allocate_attribute("version", "1.0"));
decl->append_attribute(doc.allocate_attribute("encoding", "utf-8"));
doc.append_node(decl);
// root node
xml_node<>* root = doc.allocate_node(node_element, "rootnode");
root->append_attribute(doc.allocate_attribute("version", "1.0"));
root->append_attribute(doc.allocate_attribute("type", "example"));
doc.append_node(root);
// child node
xml_node<>* child = doc.allocate_node(node_element, "childnode");
root->append_node(child);
xml_node<>* child2 = doc.allocate_node(node_element, "childnode");
root->append_node(child2);
std::string xml_as_string;
// watch for name collisions here, print() is a very common function name!
print(std::back_inserter(xml_as_string), doc);
std::cout << xml_as_string << std::endl;
// xml_as_string now contains the XML in string form, indented
// (in all its angle bracket glory)
std::string xml_no_indent;
// print_no_indenting is the only flag that print() knows about
print(std::back_inserter(xml_no_indent), doc, print_no_indenting);
// xml_no_indent now contains non-indented XML
std::cout << xml_no_indent << std::endl;
}
なぜ、xml_nodeへのポインタを使用するのですか?
私はxml_nodeを返すために、関数に必要なので、私はこれを行う場合、私はそう...
これを頼む:
xml_node <> * MYNODE = ... リターン*のMYNODEを。
大丈夫ですか?返されたノードとそのすべての子を後で使用したいからです。 このようにするとよいですか? そうでない場合、どうすればよいですか?
-1あなた自身の質問に答えるのに2人の他の人がすでに答えてくれていますし、基本的には非常に長時間巻き込まれていて、まったくコヒーレントではないと繰り返しました。また、 "図書館を見て"と言います。誰かにあなたを助けてもらうように頼んだら、答えを盗んだ後、自分自身のためにそれを理解するように誰かに伝えるように伝えます。クールではありません。 –