Hello,
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 ()
parser.setFeatu re(sax.handler. feature_namespa ces,1)
parser.setFeatu re(sax.handler. feature_namespa ce_prefixes,1)
doc = minidom.parse(" fo-file.xml",parse r)
#everything ok up to here
outlines = Evaluate("//fox:outline",do c.documentEleme nt)
I get a RuntimeExceptio n in
[pythonpath]\Lib\site-packages\_xmlpl us\xpath\Parsed NodeTest.py, 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
1.0a3.
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
getElementsByTa gNameNS, 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
Piet
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 ()
parser.setFeatu re(sax.handler. feature_namespa ces,1)
parser.setFeatu re(sax.handler. feature_namespa ce_prefixes,1)
doc = minidom.parse(" fo-file.xml",parse r)
#everything ok up to here
outlines = Evaluate("//fox:outline",do c.documentEleme nt)
I get a RuntimeExceptio n in
[pythonpath]\Lib\site-packages\_xmlpl us\xpath\Parsed NodeTest.py, 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
1.0a3.
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
getElementsByTa gNameNS, 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
Piet
Comment