Re: [lxml] Difference between findall() and xpath()

Hi, you probably meant to reply to the list. Peng Yu schrieb am 22.03.2018 um 23:11:
Does this help?
This does not explain their difference from `xpath()`. Can somebody be more explicit about the differences?
There are three differences. The main difference is the namespace representation: XPath uses an indirection through prefixes, ElementPath uses namespace URIs directly, thus matching the rest of the API. The second difference is that XPath has more features than ElementPath, but that's a bug. ;) And the third difference is that ElementPath supports iteration, whereas the XPath implementation always returns a complete result list. Well, and as I mentioned, ElementPath is usually faster than XPath, unless you hit a case that can structurally be expressed (and processed) more efficiently by the XPath implementation of libxml2. But that case is difficult to predict and requires proper measuring on real data. Stefan

There are three differences. The main difference is the namespace representation: XPath uses an indirection through prefixes, ElementPath uses namespace URIs directly, thus matching the rest of the API.
I still don't know what ElementPath refers to. This is the type of root. Is it an ElementPath?
print type(root) <type 'lxml.etree._Element'>
-- Regards, Peng
participants (2)
-
Peng Yu
-
Stefan Behnel