Error on xpath-ing a DOM with namespaces

Piet pit.grinja at
Sun Mar 6 18:36:35 CET 2005

Via Xpath, I want to access nodes which have a namespace prefix. THe
document at hand is an Xsl-FO document. I tried the following:
from xml.dom import minidom
from xml.xpath import Evaluate
from xml import sax
parser = sax.make_parser()
doc = minidom.parse("fo-file.xml",parser)
#everything ok up to here
outlines = Evaluate("//fox:outline",doc.documentElement)

I get a RuntimeException in
[pythonpath]\Lib\site-packages\_xmlplus\xpath\, line
168 because of an undefined namespace "fox"
In the xml document, the namespace "fox" is defined, e.g. it has been
assigned an URL via xmlns:fox. I have installed pyxml 0.83 and 4suite
Since I never had to deal with namespaces before, I have no real idea
what to try next. I don't like to use the DOM functions like
getElementsByTagNameNS, because xpath is more flexible. Is this error
above caused by the employed xml tools, or have I missed something
basic about xpath and namespaces in general?
Many thanks in advance

More information about the Python-list mailing list