嗨,我一直在嘗試將 div - p 標簽中的所有文本部分都放到 hr 標簽中,所以有人給出了這個 xpath
//div[@class="entry"]/*[not(preceding-sibling::hr | self::hr)]/text()
哪個作業正常,但這會忽略 p 標記中 <.a> 標記內的文本部分,是否也有任何想法來獲取該文本?
<div class="entry">
<p> some text</p>
<p> some text2</p>
<p> some text3</p>
<p> some text4
<a href='somelink'> this text here i want to get through xpath</a>
some text5
</p>
<hr>(up to this hr tag)
<p> some text5</p>
<hr>
<p> some text6</p>
</div>
uj5u.com熱心網友回復:
一種方法可能是//div[@]/*[not(preceding-sibling::hr | self::hr)]//text()盡管我可能更喜歡簡單地選擇元素//div[@]/*[not(preceding-sibling::hr | self::hr)]并使用字串值。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/329281.html
上一篇:如何讓我的重置按鈕在沒有表單的情況下在HTML中作業?
下一篇:影像顯示錯誤
