diff --git a/scrapy/selector/lxmlsel.py b/scrapy/selector/lxmlsel.py index af6839474..6e5fda556 100644 --- a/scrapy/selector/lxmlsel.py +++ b/scrapy/selector/lxmlsel.py @@ -59,7 +59,7 @@ class XPathSelector(object_ref): def extract(self): try: return etree.tostring(self._root, method=self._tostring_method, \ - encoding=unicode) + encoding=unicode, with_tail=False) except (AttributeError, TypeError): if self._root is True: return u'1' diff --git a/scrapy/tests/test_selector.py b/scrapy/tests/test_selector.py index e4197b084..284c28db6 100644 --- a/scrapy/tests/test_selector.py +++ b/scrapy/tests/test_selector.py @@ -43,6 +43,7 @@ class XPathSelectorTestCase(unittest.TestCase): self.assertEqual([x.extract() for x in xpath.select("concat(//input[@name='a']/@value, //input[@name='b']/@value)")], [u'12']) + @libxml2debug def test_selector_unicode_query(self): body = u"
" response = TextResponse(url="http://example.com", body=body, encoding='utf8') @@ -271,7 +272,6 @@ class XPathSelectorTestCase(unittest.TestCase): @libxml2debug def test_select_on_text_nodes(self): - # FIXME: can't get this to work with lxml backend r = self.hxs_cls(text=u'