Игорь Проценко Игорь Проценко - 4 years ago 105
Python Question

How to match nested italic font tags with Xpath?

Consider an

structure like the following

<p class="long">
" is the adjective based on the noun "
", which means the desire to harm others. Both words come from the latin word "

I want to select all text inside the
I tried with

examples = tree.xpath('//p[@class="long"]/text()')

With this, however, all text betweem tags is ignored for some reason.

What is the correct way to extract all the text inside the
tags, regardless of it being also contained in other nested tags?

glS glS
Answer Source

Try with


(with the double slash before text(), which also matches nodes that aren't direct children)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download