I am using libxml2 under python. Unfortunatly the python version of this library is really badly documented and i founded just few example on the web from there i could understand some of the method.
I managed the add a soon te a XML Node. Since this element should replace an existing one I would like to remove the previos one before but i could not find which is the method to remove a child.
Does anyone know what is the method name? does anyone have a decent documentation about this library?
Cheers
You can use the
unlinkNode()method to remove a given node. In general, most of the methods that apply to nodes are documented, try:For
unlinkNode, the documentation says:For example, given this input:
You can parse the file like this:
Locate the
<div>node like this:And remove it like this:
And now if you print out the document, you get this: