minidom Node to Element

Richard Lewis richardlewis at fastmail.co.uk
Fri Jun 3 12:07:37 EDT 2005


Hey,

Can I convert an xml.dom.Node object to an xml.dom.Element object? I
want to do the conversion inside a condition like this:

if node.nodeType == Node.ELEMENT_NODE:
    # do conversion:
    element = Element(node)
    element = node.toElement()

so it definitely won't cause problems. I just can't find a way to do it!

(I want to be able to call getElementsByTagName() on the resultant
object; any other workarounds which allow the same functionality would
be just as cool ;-)

Cheers,
Richard



More information about the Python-list mailing list