[xml-bindings]Minor bug in python bindings tree stuff



Hi there,

I hope this is the right forum to post this too.

The docSetRootElement() function in the python bindings is wrong (IMO) on two counts. Firstly, it should be a method of doc rather than node, and secondly it will raise an exception when the C function xmlDocSetRootElement() returns null which will happen under non-error conditions since it "Returns : the old root element if any was found" and this could well be null.

This makes it quite hard to create a document from scratch in python. A workaround goes something like this:

doc = libxml2.newDoc('1.0')
rootNode = doc.newDocNode(None, 'myrootnode', None)
# rootNode.docSetRootElement(doc)
libxml2mod.xmlDocSetRootElement(doc._o, rootNode._o)
...

All the best,
Pete (not on the list, i.e. please CC me on replies)




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