Tim Arnold, 19.06.2013 17:12:
I don't know why my lxml differs between my FreeBSD and my Windows installation. This is what I get on FreeBSD and what I expected to get:
Python 2.7.1 (r271:86832, Apr 5 2011, 13:19:14) [GCC 4.2.1 20070719 [FreeBSD]] on freebsd8 Type "help", "copyright", "credits" or "license" for more information.
from lxml import etree tree = etree.parse('generic.xml') xns = {'d': 'http://docbook.org/ns/docbook'} tree.findall('//d:section', namespaces=xns)
That returns a list of all the section elements. Help shows what I expected to see:
help(tree.findall) Help on built-in function findall:
findall(...) findall(self, path, namespaces=None)
But this, on windows 7, is not what I expected:
C:\Windows\system32>python Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
from lxml import etree tree = etree.parse("e:/generic.xml") xns = {'d': 'http://docbook.org/ns/docbook'} tree.findall('//d:section', namespaces=xns) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: findall() takes no keyword arguments
And help shows this:
help(tree.findall) Help on built-in function findall:
findall(...) findall(self, path)
Finds all elements matching the ElementPath expression. Same as getroot().findall(path).
So have I done something wrong with my install?
Not wrong, but you apparently installed two different lxml versions. Try print lxml.__version__ Stefan