c++ - boost ptree: Adding more nodes with same name and attributes -


i'm trying write xml more nodes , attributes same name this:

<parameterset>     <parametersettype name="aaaa">     </parametersettype>     <parametersettype name="bbbb">      </parametersettype>     <parametersettype name="cccc">     </parametersettype> </parameterset> 

i tried use pt.put() obtaining last element

<parameterset>     <parametersettype name="cccc">     </parametersettype> </parameterset> 

and pt.add() obtaining 1 node attributes

<parameterset>     <parametersettype name="aaaa" name="bbbb" name="cccc">     </parametersettype> </parameterset> 

what correct way want?

according property tree documentation pt.add() right function use:

template<typename type>    self_type & add(const path_type & path, const type & value);  

if node identified path not exist, create it, including missing parents. if node exists, add sibling same key. set newly created node's value given paremeter, translated supplied translator.

again referencing documentation time tutorial give following example of adding string std::list property tree:

boost_foreach(const std::string &name, m_modules)       pt.add("debug.modules.module", name); 

which results in following:

<debug>    <modules>         <module>finance</module>         <module>admin</module>         <module>hr</module>     </modules> </debug> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -