[XML-SIG] PyXML XPath woes

Thomas B. Passin tpassin at comcast.net
Sat Feb 7 21:49:14 EST 2004

Matt Patterson wrote:
> I've got an XML file in which I want to locate all elements with the 
> attribute boundary set to 'true'. I use the following XPath with 4DOM:
> //*[@boundary='true']
> like so:
> boundaryFinder = Compile("//*[@boundary='true']")
> context = Context(self.document)
> # evaluate the expression and get a nodeList
> boundaryNodes = boundaryFinder.evaluate(context)
> But the results of the XPath do not return all the nodes which match!

How many nodes did you get and how many are actually there?

You have an encoding problem with the file you linked to.  It is encoded 
in iso-8859-1 but with no encoding declaration it is treated as utf-8. 
Unfortunately there are some non-utf-8 characters in it, so it is not 
well-formed.  Thus any results you get would be suspect.  In fact, it 
should not parse sucessfully at all.

Once I added an encoding declaration for iso-8859-1, running the xpath 
expression in XML Cooktop I got 47 @boundary nodes, the same as Luis 
Miguel said he found.

Fix your encoding (I have no idea how you will do that, but presumably 
either a Framemaker setting or a bit more preprocessing would do it). 
Then follow Luis Miguel's example and see if you get the same results.


Tom P

More information about the XML-SIG mailing list