选择第一个<p>标签,任何人都可以知道下面代码的 xpath 是什么?



<div class="main-banner"><img alt="Health and Safety In Care" height="291px" width="650px" class="img-responsive" height="291px" Width="650px" src="images/Care Safety.jpg" /></div>  
<p>It is a legal requirement that those in the care sector must have sufficient health and safety training to ensure the safety of both staff and patients.</p>
<p>The below range of health and safety courses specialise in handling different equipment and scenarios often encountered in the care sector. Our courses boast accreditation from the CIEH and HABC, and are designed to fulfil recommendations made by the CQC.</p>

选择xpath的 <p>标签在以下 <div>标签之后包含 main-banner类。

<div class="main-banner"><img alt="Health and Safety In Care" height="291px" width="650px" class="img-responsive" height="291px" Width="650px" src="images/Care Safety.jpg" /></div>  
<p>It is a legal requirement that those in the care sector must have sufficient health and safety training to ensure the safety of both staff and patients.</p>
<p>The below range of health and safety courses specialise in handling different equipment and scenarios often encountered in the care sector. Our courses boast accreditation from the CIEH and HABC, and are designed to fulfil recommendations made by the CQC.</p></div>

选择 1 st <p>class="main-banner"<div>节点之后:

(//div[@class="main-banner"]/following-sibling::p)[1]

--------------

如果关键的<div>节点在类属性中具有多个项目,例如class="cont baseline main-banner"使用以下 xpath 表达式:

(//div[contains(@class,"main-banner")]/following-sibling::p)[1]

xpath:

  //div[@class="main-banner"]/following-sibling::p [1]

相关内容

最新更新