Reputation: 750
I have been looking for a while a python module/API that does something I believe is quite simple:
So far I've found several snippets that interface with complicated object oriented databases, but nothing dead simple as:
xml = etree.parse ('file.xml')
xml.add(xpath, new_node(attrs))
xml.remove(xpath)
xml.edit(xpath, new_attrs(attrs))
xml.write()
Most surely I'm misunderstanding the API, but some light will be very welcome.
Thanks in advance !
Upvotes: 0
Views: 365
Reputation: 1702
There are solutions from the standard library too. I think clear()
from xml.etree.ElementTree should work as desired. On the other hand, if you have no problem with external dependencies, I think, not sure though, that lxml provides a faster solution.
Upvotes: 0
Reputation: 74705
Did you checkout the lxml.etree tutorial? It has enough examples to show you how to do most of what you want.
Upvotes: 2