Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Rapidxml和开始标记_C++_Xml_Eclipse_Rapidxml - Fatal编程技术网

C++ Rapidxml和开始标记

C++ Rapidxml和开始标记,c++,xml,eclipse,rapidxml,C++,Xml,Eclipse,Rapidxml,我在使用rapidxml时遇到了一些问题。当我编译我的代码时,没有开始标记。任何和所有的帮助都将不胜感激 int main(){ xml_document<> doc; //xml declaration xml_node<>* decl = doc.allocate_node(node_declaration); decl->append_attribute(doc.allocate_attribute("version

我在使用rapidxml时遇到了一些问题。当我编译我的代码时,没有开始标记。任何和所有的帮助都将不胜感激

    int main(){


    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, "root");
        root->append_attribute(doc.allocate_attribute(""));
                    doc.append_node(root);
                // child/sibling node
        xml_node<>* sibling0 = doc.allocate_node(node_element, "old");
        root->append_node(sibling0);
        xml_node<>* sibling = doc.allocate_node(node_element,"boy");
        root->append_node(sibling );
                 std::string xmlstring;
        print(back_inserter(xmlstring), doc);
        cout << xmlstring << endl;}

除了必要的include之外,还缺少使用名称空间rapidxml的功能;你的代码对我来说编译和运行都很好

xmlstring包含以下内容:

<?xml version="1.0" encoding="utf-8"?>
<root ="">
    <old/>
    <boy/>
</root>

因为old和boy没有内容,所以他们使用xml空元素标记,而不是像这样的开始和结束对

您得到了什么输出?