Re: [xml] Changing the content of a node

Marc Tajchman schrieb am 07.06.2012 um 12:53 (+0200):

2: <data>
3: <level1>
4:      some_text
5: <level2>
6: <level3>2.5</level3>
7: </level2>
8: </level1>
9: </data>

Both text and elements as children of level1.
This is called "mixed content".

and I want to modify the content at <level1> node, i.e. replace
"some_text" by "modified_text"

After using xmlNodeSetContent, the tree becomes :

1: <?xml version="1.0"?>
2: <data>
3: <level1>
4:       modified_text
5': </level1>
6': </data>

How to keep the <level2> subtree (lines 5 to 7 of the original XML) ?

I would say: Locate the text node in question, prepend the new text
node, then remove the original one. I'm not a C API user, but you
should be able to find the functions needed by scanning what's there.


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