首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rapidxml和start标记

Rapidxml和start标记
EN

Stack Overflow用户
提问于 2013-10-23 13:56:26
回答 1查看 169关注 0票数 1

我在rapidxml上遇到了一些问题。当我编译我的代码时,没有一个开始标记是included..any,所有的帮助都会受到极大的感谢。

代码语言:javascript
复制
    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;}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-01 11:27:28

除了必要的# using namespace rapidxml;之外,您的代码为我编译并运行良好。

xmlstring包含以下内容:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<root ="">
    <old/>
    <boy/>
</root>

因为oldboy没有内容,所以它们使用xml空元素标记(<tagname/>),而不是像<tagname></tagname>这样的开始和结束对。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19543711

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档