
May 6, 2013
3:37 p.m.
Le 06/05/2013 18:41, Eric Levy a écrit :
Currently, the apply_templates call is failing, with the following error:
TypeError: invalid argument type <type 'list'>
Hi, That seems pretty self-explanatory. XPath returns a list of results, and according to the doc[1] example apply_templates() expects a single element object. [1] http://lxml.de/extensions.html If your XPath expression is constructed such that there is exactly one result, use `foo[0]` to extract it from the list. If you use `text()` in XPath or something such that results are strings rather than element objects, you might need to construct a dummy object to pass to apply_templates(): el = lxml.etree.Element('dummy') el.text = xpath_results[0] -- Simon Sapin