<div id="Dossuuu11Plus" style="display: block; ">
Text need
<br/>
Not need
<a class="bot_link" href="http://abc.com" target="_self">http://abc.com</a>
<br/>
</div>
这是 html 代码。我使用://td[@class='textdetaildrgI但它得到了所有内容,我只需要"文本需要"。请帮助我。谢谢
您可以使用
//div[@id='Dossuuu11Plus']/text()[1][normalize-space()]
解释:它将选择为DIV
找到的第一个文本节点,在本例中Text need
,normalize-space()
将修剪前导和尾随空格(如果有(。