[xml] Pasting fragment



Title: Pasting fragment

Help!

In what seems to be a simple task, I am making many mistakes, and I need
help.

I have an xmlNodePtr, and I have a section of xml text that I would like
to add as a child (or children).

xmlNodePtr activeNode; // somewhere in my document...
std::string newText = "<child>data1</child><child>data2</child>";

My goal is to end up with my activeNode having the two new child nodes as
children, with the corresponding text values, and whatever else may be
inside the newText.

How do I accomplish this?  I don't want to have to parse the text myself,
I want to use something like xmlParseMemory.  But first I need to add a
"<father>" to the front, and "</father>" to the end, so that it would be
a well formed document, right?

Then I'm having trouble ensuring that the children remain, after I
xmlFreeDoc.  I was trying to use xmlNewDocFragment and xmlAddChild, but
that didn't seem to do what I needed.

Help!

Thanks!
-Matt

// Matt Cruikshank (763)852-4183
// <mcruikshank vitalimages com>
void s(int&A,int&B){A^=B^=A^=B;}



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