[xml] Problem with xmlAddChild



Hello,

I'm currently hacking on the lightspark project (free Adobe Flash
implementation), which uses libxml2 and libxml++. In ActionScript it is
possible to add nodes in reverse order, e.g.:
                var xml1:XML=new XML("<test1></test1>");
                var xml2:XML=new XML("<test2></test2>");
                var xml3:XML=new XML("<test3></test3>");
                xml1.appendChild(xml2);
                xml2.appendChild(xml3);

Now the problem is that xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
merges adjacent text nodes and cur is freed (making it impossible to add
something to cur later). It seems to work at first, but the memory gets
corrupted (surprise!). With libxml++'s import_node there is no
corruption, but the xml3-element doesn't get added at all.

Is there a possible workaround where the node structure doesn't get
touched by appendChild or do I have to re-implement that method (which
probably would require accessing the underlying structures directly and
hence be rather ugly).

Thanks in advance for your help.

~Fabian


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