How to parse strings representing xml.dom.minidom nodes in python?
Posted
by Francis Davey
on Stack Overflow
See other posts from Stack Overflow
or by Francis Davey
Published on 2010-05-23T11:54:05Z
Indexed on
2010/05/23
12:10 UTC
Read the original article
Hit count: 365
I have a collection of nodes xml.dom.Node objects created using xml.dom.minidom. I store them (individually) in a database by converting them to a string using the toxml() method of a the Node object.
The problem is that I'd sometimes like to be able to convert them back to the appropriate Node object using a parser of some kind. As far as I can see the various libraries shipped with python use Expat which won't parse a string like '' or indeed anything which is not a correct xml string.
So, does anyone have any ideas? I realise I could pickle the nodes in some way and then unpickle them, but that feels unpleasant and I'd much rather be storing in a form I can read for maintenance purposes. Surely there is something that will do this?
© Stack Overflow or respective owner