Closed GoogleCodeExporter closed 9 years ago
append_copy will always be able to append the node to the document, as long as
child.m_XmlNode.type() returns something that's not node_document or node_null.
Can you confirm the return value of child.m_XmlNode.type()?
Original comment by arseny.k...@gmail.com
on 28 Dec 2012 at 8:53
Return value of child.m_XmlNode.type() is 2 i.e. node_document.
Original comment by kshitija...@gmail.com
on 28 Dec 2012 at 9:14
append_copy can not append the document as a child, since that would result in
nested documents, which is not allowed.
If the expected type was indeed the document, then you can manually append all
children like this:
for (pugi::xml_node c = child.m_XmlNode.first_child(); c; c = c.next_sibling())
doc.append_copy(c);
If, however, you expected child.m_XmlNode to be an element instead of a
document, you have to check your code to discover why it's not an element.
Original comment by arseny.k...@gmail.com
on 28 Dec 2012 at 9:47
[deleted comment]
[deleted comment]
<node>
<node1>
<node2>
</node2>
</node1>
<node>
Using code given by you, can we append "node" along with all child nodes?
What about the reset()?
Original comment by kshitija...@gmail.com
on 28 Dec 2012 at 10:19
Yes, this code appends the node with all child nodes - note that append_copy
appends the entire subtree. The reason the loop is necessary at all is to cope
with document restriction.
doc.reset(doc) is equivalent to doc.reset() and should not be needed unless you
do want to remove all nodes from the document before proceeding.
Original comment by arseny.k...@gmail.com
on 28 Dec 2012 at 3:42
If I dont use doc.reset(doc), it is not appending the node. Any solution for
this?
Original comment by kshitija...@gmail.com
on 31 Dec 2012 at 5:29
Normally doc.reset is not needed. I can't think of a case where it would be
necessary for append_copy to work - can you provide a larger code example that
exhibits the problem?
Original comment by arseny.k...@gmail.com
on 31 Dec 2012 at 6:18
Original comment by arseny.k...@gmail.com
on 3 Mar 2013 at 3:04
I want to create a node in document. And again append that same node in that
document only. I am using append_child to create node and append_copy to append
node.
Original comment by kshitija...@gmail.com
on 20 Sep 2013 at 9:55
Original issue reported on code.google.com by
kshitija...@gmail.com
on 28 Dec 2012 at 7:11