如何使用Rapidxml创建xml节点

问题描述 投票:0回答:1

[嗨,我想在Linux上使用Rapidxml在C ++中创建以下xml文件。如何添加类型为name

的元素
    <wrapit>
       <mainNode>
          <name>something1</name>
       </mainNode>
    </wrapit>

我的代码生成的内容看起来像是我不想要的。

    <wrapit>
       <mainNode>
          <name something1=""/>
       </mainNode>
    </wrapit>

我为此找不到很多信息。在wordpress上很少,但xml格式不同。

代码段

xml_node<>* root = doc.allocate_node(node_element, "mainNode");
doc.append_node(root);
xml_node<>* child = doc.allocate_node(node_element,"name");
child->append_attribute(doc.allocate_attribute("something1"));
root->append_node(child);
c++ linux rapidxml
1个回答
0
投票

ugg ....

xml_node<>* child = doc.allocate_node(node_element,"name","something1"); 

完成。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.