[lxml-dev] XPath exceptions

Stefan Behnel stefan_ml at behnel.de
Wed May 16 10:19:33 CEST 2007



jholg at gmx.de wrote:
> a quick question on nsmaps in XPath:
> Is it intentional that this
> 
>>>> root = etree.fromstring("<root><a>what?</a></root>")
>>>> root.xpath("//a", {'':'my/foo/bar/URI'})
> ['what?']
>>>> root.xpath("//a")
> ['what?']
> 
> but 
> 
>>>> root = etree.fromstring("<root xmlns='my/foo/bar/URI'><a>what?</a></root>")
>>>> root.xpath("//a", {'':'my/foo/bar/URI'})
> []
> 
> does not?

No. Passing an empty prefix should raise the same exception as passing None.
Fixed on the trunk.

Stefan



More information about the lxml-dev mailing list