only a simple xml reader <tag:id>value</tag:id>

martijn at gamecreators.nl martijn at gamecreators.nl
Wed Feb 8 03:39:53 EST 2006


H!,

Is it possible to get a <tag:id>value</tag:id> value ?

When I do this:
-----------------------------------------------------
theXML = """<?xml version="1.0"?>
    <title>The Fascist Menace</title>
"""
import xml.dom.minidom as dom
doc = dom.parseString(theXML)
print doc.getElementsByTagName('title')[0].toxml()

I get : <title>The Fascist Menace</title> thats oke for me
-----------------------------------------------------

But the xmlfile I must read have other tags:
theXML = """<?xml version="1.0"?>
    <title:id>The Fascist Menace</title:id>
    <title:name>bla la etc</title:name>
"""

how to get that values ?
I try things like:
print doc.getElementsByTagName('title:id')[0].toxml() <--error

Thanks,
GC-Martijn




More information about the Python-list mailing list