xpath 和自关闭 <br/> [英] xpath and self closing <br/>
本文介绍了xpath 和自关闭 <br/>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我如何访问 < 之后的文本?br/> 在下面?
Can anyone tell me how I can access the text after the < br / > in the following?
<li>
<span class="title">Size</span>
<p>Ladies<br />Case Diameter: 27.0 mm</p>
</li>
出于某种原因,我无法通过它......但是,我可以得到它前面的东西(女士们)
For some reason, I cannot get past it... however, I CAN get whats in front of it (Ladies)
谢谢!
推荐答案
使用:
/*/p/br/following-sibling::text()[1]
请注意表达式的问题:
/li/p/br/following-sibling::text()
根据 XML 文档,这可能会选择 br
的兄弟姐妹之后的多个(实际上是所有)文本节点,但是您只需要紧跟 br
的文本节点>.
Depending on the XML document this may select more than one (actually all) text-node following siblings of br
, however you only want the text node that immediately follows br
.
这篇关于xpath 和自关闭 <br/>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文