Home > Blockchain >  How to exclude specfic element through Xpath expression
How to exclude specfic element through Xpath expression

Time:02-18

I want to write an XPath expression that can select all of the <p> but exclude p[6] and p[7]. I have written this expression //div[@]/p[1] it is working great but i don't want to add p[6] and p7]. I am writing this Xpath expression for a screenscraper.

<div ><h4>JOB DESCRIPTION</h4><p><b>Setting: </b>Hospital<br><p>Currently offering positions for Registered Nurses with experience caring for patients that require complex monitoring and nursing interventions due to brain, head or spinal cord injuries, brain infections, brain tumors, epilepsy and other seizure disorders, nerve and muscular disorders, strokes and more for a 13 week contract at a state-of-the art hospital.</p>
<p>At Jackson you’ll enjoy a supportive, ambitious culture focused on making sure talented nurses like you can do your best work in the most positive work environments possible since 2006. &nbsp;</p>
<p><strong>Minimum Requirements:</strong></p>
<ul>
<li>Current state license in good standing with State License Board.&nbsp;</li>
<li>12 months NEURO ICU experience in an acute-care setting within the last 3 years. &nbsp;</li>
<li>At minimum, current BLS required (certifications vary by location – job may require ACLS).</li>
<li>Medical Records.</li>
</ul>
<p><strong>Benefits &amp; Perks</strong></p>
<p>We deeply value your commitment to improving the lives of patients, that’s why we offer a comprehensive and competitive benefits package starting your first day. </p>
<ul>
    <li>Full Medical Benefits &amp; 401k Matching Plan </li>
    <li>24/7 Recruiter: Your main point of contact available by text, phone, or email </li>
    <li>Competitive Referral Bonuses </li><li>100% Paid Housing Available </li>
    <li>Travel &amp; License Reimbursement</li>
</ul>
<p>Apply now and you’ll be contacted by a recruiter who will give you more information on this or other RN vacancies in the settings and locations that matter most to you.</p>
<p><small><i>
    <strong>EEO Statement</strong><br>
    Jackson Healthcare and its family of companies are an EEO/AA Employer. All qualified applicants will receive consideration for employment without regard to race, color, religion, sexual orientation, gender, gender identity and expression, national origin, age, disability or protected veteran status. We celebrate diversity and are committed to creating an inclusive environment for all of our associates.
</i></small></p><p><i>Northeast, Travel, Hospital</i></p><h4>SEARCH TAGS</h4><p></p><div><ul ><li><span>Northeast</span></li><li><span> Travel</span></li><li><span> Hospital</span></li></ul></div><p></p></p></div>

Is there a way to exclude these two elements?

CodePudding user response:

In case the only indication of the elements you want to exclude is that they are number n in the list of matching elements the only way to do that is to collect all the elements matching your XPath into a list and then exclude the unwanted elements indexes while iterating over the list of nodes / elements matching that XPath.

CodePudding user response:

Yes, but I think you missing the important information under the minimum requirement headline.

//div[@]/p[position() !=6 and position() !=7]

This xpath should skip the 6 and 7th index p tag elements

  • Related