Re: [xml] extend xml Document with new rootNode

On Sun, 2003-10-19 at 04:45, Marc Giger wrote:
Hi list,

I'm new to libxml and need some help.

What I try to do is to extend an existing xml-document with a new root
node. I've already tried some things...

To illustrate the "problem", the actual xml file is something like the

Call this doc1

<?xml version="1.0"?>

And the goal should be:

And this is doc2

<?xml version="1.0"?>

What is the best way to achieve this?
Perhaps it is relevant that the xml-tree will never be written out to a
file. It's processed "in memory".

From doc1 use xmlDocGetRootElement to get the xmlNodePtr for the root
node (<data>). Then in doc2 walk the tree*, and when you got to <body>,
use xmlAddChildList to add the root node tree bit from doc1.


* or for how to walk the tree

John Fleck
jfleck inkstain net (h)

"It makes me mad when someone writes or draws
 something that I can't get right away!"
 - Zippy the Pinhead

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]