Xpath 位置() 函数

Xpath Position() function

我想按位置匹配特定元素。这是代码

<div class="field-content">
  <p><strong>*** Due to the large need for nurses during the coronavirus outbreak, many of the nursing jobs listed below have flexible start dates and assignment lengths. Even if you are unable to start on the designated Start Date, please apply and discuss your availability with a Fastaff recruiter. ***</strong></p>
  <p>The Estimated Weekly Total is based on working the listed number hours per week and includes available stipend amounts; eligibility may vary subject to company policy and applicable law. Please contact a recruiter for full details.</p>
  <h2>Medical Surgical / Telemetry Travel Registered Nurse Job</h2>
  <p>We are seeking an experienced and self-motivated medical surgical / telemetry travel registered nurse to join our growing team of registered nursing professionals.</p>
  <h3>Medical Surgical / Telemetry RN Qualifications:</h3>
  <ul>
    <li>Active RN license in specified state</li>
    <li>RN degree from an accredited registered nurse program</li>
    <li>BLS and ACLS required</li>
    <li>One year of recent experience as an RN in a medical surgical / telemetry environment and two years of RN experience</li>
  </ul>
  <h3>Medical Surgical / Telemetry Registered Nurse Duties &amp; Responsibilities:</h3>
  <ul>
    <li>Manage the care of adult patients experiencing cardiac problems requiring moderately complex assessment, therapies and interventions</li>
    <li>Communicate and educate patients and families</li>
    <li>Assess and coordinate patients’ discharge planning needs with members of the healthcare team</li>
    <li>May require interpretation of cardiac rhythm strips and provision of appropriate nursing treatment</li>
  </ul>
  <h3>Benefits of Being a Fastaff® Travel Nursing Employee</h3>
  <ul>
    <li>Premium pay</li>
    <li>Prestigious facilities</li>
    <li>Flexible scheduling</li>
    <li>Immediate access to the industry’s best RN recruiters and healthcare facilities</li>
    <li>Fastaff will provide costs for housing during the length of your assignment, as well as airfare or mileage to and from the city of the assignment at the start and end of the assignment.</li>
    <li>Group health insurance benefits</li>
    <li>,000 Company-paid Life/ADD Insurance</li>
    <li>Matching 401(k)</li>
  </ul>
  <h3>About Fastaff® Travel Nursing:</h3>
  <p>More than two decades ago, Fastaff pioneered the practice of Rapid Response<strong>®</strong>&nbsp;travel nurse staffing. Since then, the company has grown to become the leading provider of urgent and crucial temporary registered nurses to help hospitals
    provide continuous, high-quality patient care, while offering premium pay to registered nurses. In partnering with many of the nation’s largest and most prestigious healthcare facilities as well as small community hospitals, Fastaff provides enriching
    employment opportunities to RNs while also providing the highest pay in the industry to meet acute staffing needs and provide unparalleled patient care.</p>
  <p><em>Fastaff Travel Nursing is an equal employment opportunity employer. Fastaff’s policy is not to unlawfully discriminate against any applicant or employee on the basis of race, color, sex, religion, national origin, age, military status, disability, genetic information or any other consideration made unlawful by applicable federal, state, or local laws. Fastaff also prohibits harassment of applicants and employees based on any of these protected categories. It is also Fastaff’s policy to comply with all applicable state and federal laws respecting consideration of unemployment status in making hiring decisions.</em></p>
</div>

我想要 select 小于或等于 8 的元素,像这样 //div [contains (@class, "field-content")]//following-sibling::*[position() <=8] 但它给我的结果与此 //div [contains (@class, "field-content")]//following-sibling::*[position() >=8] 表达式给出的结果相同。

<div class="field-content">
  <p><strong>*** Due to the large need for nurses during the coronavirus outbreak, many of the nursing jobs listed below have flexible start dates and assignment lengths. Even if you are unable to start on the designated Start Date, please apply and discuss your availability with a Fastaff recruiter. ***</strong></p>
  <p>The Estimated Weekly Total is based on working the listed number hours per week and includes available stipend amounts; eligibility may vary subject to company policy and applicable law. Please contact a recruiter for full details.</p>
  <h2>Medical Surgical / Telemetry Travel Registered Nurse Job</h2>
  <p>We are seeking an experienced and self-motivated medical surgical / telemetry travel registered nurse to join our growing team of registered nursing professionals.</p>
  <h3>Medical Surgical / Telemetry RN Qualifications:</h3>
  <ul>
    <li>Active RN license in specified state</li>
    <li>RN degree from an accredited registered nurse program</li>
    <li>BLS and ACLS required</li>
    <li>One year of recent experience as an RN in a medical surgical / telemetry environment and two years of RN experience</li>
  </ul>
  <h3>Medical Surgical / Telemetry Registered Nurse Duties &amp; Responsibilities:</h3>
  <ul>
    <li>Manage the care of adult patients experiencing cardiac problems requiring moderately complex assessment, therapies and interventions</li>
    <li>Communicate and educate patients and families</li>
    <li>Assess and coordinate patients’ discharge planning needs with members of the healthcare team</li>
    <li>May require interpretation of cardiac rhythm strips and provision of appropriate nursing treatment</li>

这些是 HTML 中我想要 select 但表达式与它们不匹配的元素。我正在 Chrome Devtools

中编写 XPath 表达式

当您想要的节点是 children.

时,您正在使用 following-siblings

而是select某个位置的所有child人:

//div[contains (@class, "field-content")]/*[position() >= 8]

此 select 此 div 节点的任何直接 child 位置 >=8.

有关更多信息,请参阅 this interactive xpath tester