ElementTree find with xmlns

cakebread cakebread at gmail.com
Sat Oct 13 05:19:02 CEST 2007


I'm having problems parsing a file:

>>> tree = ElementTree.fromstring("""<html xmlns="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:doap="http://usefulinc.com/ns/doap#">
<body>Hello world</body>
</html>""")

>>> print tree.find('body')
None

The above works fine with the first element being a simple <html>, but
not when I have all the xmlns's.

Thanks,
Rob




More information about the Python-list mailing list