Xpath一起获取父标记和子标记的内容

时间:2014-04-28 13:49:49

标签: html xpath

<div class="inner_body_left">
<li>
Lake 2014: 9th Biennial Lake Symposium on "
<a target="_blank" href="/events/CES_TVR_LAKE_2014_brochure_2FEb2014.pdf">Conservation   of Wetland Ecosystems in Western Ghats</a>
", 13-15th November 2014
</li>
</div>

在这里,我想获得西湖高尔夫球场第9届双年湖湿地生态系统保护研讨会&#34;。有没有办法用单一的Xpath表达式获得li标签和标签的内容?提前谢谢。

1 个答案:

答案 0 :(得分:0)

您可以使用以下 XPATH ,使用string-join

string-join(//li/text(),"")

<强>输出

Lake 2014: 9th Biennial Lake Symposium on "", 13-15th November 2014

或者,使用translate来满足您的需求: -

translate(string-join(//li/text(),""),'",','')

<强>输出

Lake 2014: 9th Biennial Lake Symposium on  13-15th November 2014