On Wed, Nov 05, 2008 at 04:56:11PM +0100, Martin Trappel wrote:
Hi all!
a) Given a xmlNodePtr, is it still valid after modifying the document?
b) Given the xmlChar* Value of an attribute, is it still valid after
modifying the node/document ?
[code]
xmlDoc* doc;
...
xmlNode* doc_node = (... obtain node of doc ...);
xmlChar* node_attrib_val = xmlGetProp(doc_node, "TEST");
...
// Modify the doc, possibly adding and removing other nodes
...
doc_node->... (Is the NodePtr still valid?)
...
// Modify the node by adding or removing Attributes/Properties
...
printf("%s", (const char*)node_attrib_value); // attribute value still
valid??
[/code]
Does libxml2 guarantee this? (v 2.6.27)
I think yes. The only danger I can think of is colapsing of adjacent
text nodes, and namespace references, that's the only cases were a node
not directly used in a tree modification may change or vanish due to
the modification side effects,