私はこのTDに含まれているテキスト全体を取得しようとしている:PythonでTDの全文を取得する(lxmlの)
例:タグの多くは、この内側にあります
<td>
<p>Some Text</p>
<a>SAMPLE</a>
<table>
<tbody>
<tr>
<td>something</td>
....
</tr>
...
</tbody>
</table>
...
</td>
td、それは私のためにそれを難しくします。テーブルも含まれています。
FirePath(Firefoxの)において
私は単に取り付けることができる//テキスト()
.//*[@ ID = 'Testcases__list'] /テーブル/ TBODY/TR/TD //テキスト()
しかし、Pythonコードで//テキスト()の部分は
Traceback (most recent call last):
File "D:\pythonscripts\Bachelor\TestMain.py", line 52, in <module>
print tr.findall('./td[6]//text()')[0].text
File "src\lxml\lxml.etree.pyx", line 1563, in lxml.etree._Element.findall (src\lxml\lxml.etree.c:56897)
File "C:\Python27\lib\site-packages\lxml\_elementpath.py", line 304, in findall
return list(iterfind(elem, path, namespaces))
File "C:\Python27\lib\site-packages\lxml\_elementpath.py", line 277, in iterfind
selector = _build_path_iterator(path, namespaces)
File "C:\Python27\lib\site-packages\lxml\_elementpath.py", line 260, in _build_path_iterator
selector.append(ops[token[0]](_next, token))
KeyError: '()'
lxmlのライブラリを使用して、私にエラーがスローされますどのように私はPythonでそのTDの全文を入手できますか?
なぜちょうど '文字列(.//*[@ ID = 'Testcases__list'] /テーブル/のtbody/TR/TD)'使用しないで - ごとに[ docs](http://stackoverflow.com/documentation/xpath/1903/finding-elements-containing-specific-text/6209/find-all-elements-with-certain-text#t=201610140847415913303)、繰り返すのではなく各テキストノードの子孫ですか? –