2

I want to copy a subtree from one ptree to another.
i.e.
src:

<abc>
<question>
--some-subtree--
</question>
</abc>


and generate:

<def>
<Version>1</Version>
<QueueQuestion>
--same-subtree-as-above--
</QueueQuestion>
</def>


do something like:

ptree genReply(const ptree &pt)
{
ptree ret;
ret.put("def","");
ptree &subtree=ret.find("def")->second;
subtree.put("Version",1);
...
...
...
const Xml::ptree &q=pt.find("abc.Question")->second;
subtree.put_child("QueueQuestion",q);
...
...
return ret;
}

However, I get a segmentation fault on subtree.put_child("QueueQuestion",q);

Any idea anyone?

Null
  • 1,950
  • 9
  • 30
  • 33
Erez
  • 71
  • 4
  • What Mats wants to indicate: there is some code missing in the example, that might be needed to solve the problem. unrelated: welcome to stack overflow. :) – scones Apr 04 '13 at 13:49
  • i seems that pt.find("tag")->second causes trouble and should be replaced with pt.get_child("tag") also x.put_child should be replced with adding the child and doing y=x.get_child("tag");y.insert(y.begin)(,q.begin(),q.end()) see also [link](http://stackoverflow.com/questions/7590370/boost-property-tree-iterators-to-an-element-for-inserting) – Erez Apr 04 '13 at 13:55

0 Answers0