-1

Hi I want to create the following xml file in C++ using rapidxml on Linux. How to add an element which is of type name.

    <wrapit>
       <mainNode>
          <name>something1</name>
       </mainNode>
    </wrapit>

what my code generates looks like following which I don't want.

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

I could not find much information for this. Few on wordpress but the xml formats are different.

Code snippet

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);
punith
  • 1,169
  • 1
  • 13
  • 17

1 Answers1

0

ugg....

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

does it.

Jack Fleeting
  • 16,520
  • 5
  • 16
  • 39
punith
  • 1,169
  • 1
  • 13
  • 17