falcong / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

Adding a node to recreate XML #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Use this request type if there is something you need to do with pugixml and
you don't know how.

What do you need to do with pugixml? Please provide a description of the
problem along with sample usage scenario.

I am looking to recreate a XML, that I parsed using pugixml and stored in a sql 
table. I want to create/set name and value for a node before adding it to the 
doc or its parent. Is that possible?

Original issue reported on code.google.com by devesh...@gmail.com on 18 Jul 2011 at 10:52

GoogleCodeExporter commented 9 years ago
Nodes do not exist without the document, because the document takes care of 
memory management for node data. So the only efficient way to build XML tree is 
top-to-bottom.

If we're still talking about nested set model, the nodes in the database should 
have the tree traversal order, meaning that when you get to node A, it's parent 
is already processed (i.e. it's already in the document).

Original comment by arseny.k...@gmail.com on 18 Jul 2011 at 11:00

GoogleCodeExporter commented 9 years ago
Exactly, I am still in the Nested Set model.
So the best way I see as per your suggestion is a Breadth First Traversal of 
the tree.
Can you suggest a way to do it as I am confused designing an algo for the same.

Original comment by devesh...@gmail.com on 18 Jul 2011 at 11:21

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Given that a when I reach a node A, its parent is already processed and is 
present in the document, how do I find the parent and append this node it its 
respective parent.

Original comment by devesh...@gmail.com on 18 Jul 2011 at 11:29

GoogleCodeExporter commented 9 years ago
I'm attaching an example of XML <-> nested set conversion using pugixml (note 
that this implementation is not really pugixml-specific; it does not even use a 
node->(left,right) map).

Original comment by arseny.k...@gmail.com on 20 Jul 2011 at 4:59

Attachments:

GoogleCodeExporter commented 9 years ago
Closing the issue; if there's anything else, feel free to update it and I'll 
reopen it.

Original comment by arseny.k...@gmail.com on 22 Jul 2011 at 5:21