Reputation: 773
I am trying to all p
elements located between two h5
elements. The starting h5
text is "Subject" and the second h5
text is "tenders file".
You may see the picture attached as well.
I don't want to have other p
elements which are coming after the second h5
.
I have tried the following XPath:
//p[preceding-sibling::h5//*[contains(text() , 'SUBJECT')] and following-sibling::h5//*[contains(text() , 'Tender’s Files,')]] trying to get idea from [enter link description here][2]
but could not get the right paragraphs. It still selects other paragraphs after the second h5
.
<div>
<table class="table table-striped table-bordered table-hover" width="90%">
<tbody>
<tr>
<td style="vertical-align: middle;" colspan="2" width="90%">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Tender Title:</span> Testing of Non-Fortified Wheat Flour in NES</strong></h5>
</td>
</tr>
<tr>
<td style="vertical-align: middle;" width="45%">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Tender No:</span> SYRIA-TA-2021-005</strong></h5>
</td>
<td style="vertical-align: middle;">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Location:</span> North East Syria</strong></h5>
</td>
</tr>
<tr>
<td style="vertical-align: middle;" colspan="2">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Tender Package Available from:</span> 2021-01-10</strong></h5>
</td>
</tr>
<tr>
<td style="vertical-align: middle;" colspan="2">
<h5 style="padding-left: 10px;"><strong><span style="color: #3577be;">Deadline for Offer Submission:</span> 2021-01-18 17:00 (Iraqi Time)</strong></h5>
</td>
</tr>
</tbody>
</table>
<table class="table " width="90%">
<tbody>
<tr>
<td style="text-align: center;"> </td>
</tr>
</tbody>
</table>
<h5><strong><u>SUBJECT:</u></strong> <strong>Testing of Non-Fortified Wheat Flour in NES</strong></h5>
<p>Our organization, a non-profit organization, provides humanitarian assistance to “people in need”, is seeking quotations from eligible contractors to <strong>Testing of Non-Fortified Wheat Flour in NES</strong>. Our organization anticipates awarding Multiple or Single contract(s) as a result of this Solicitation. Our organization reserves the right to award more or none under this RFQ.</p>
<p>All bids shall be submitted <strong>via e-mail to</strong> <span id="cloak1f9ac73a082c1f52174ccee4f406b81c"><a href="mailto:[email protected]"><strong>[email protected]</strong></a></span> <strong>as PDF format and clearly written the subject of the tender</strong> This RFQ is in no way obligates our organization Our organization to award a contract nor does it commit our organization to pay any cost incurred in the preparation and submission of a proposal.</p>
<p>Our organization bears no responsibility for data errors resulting from transmission or conversion processes.</p>
<p> </p>
<ul>
<li><strong>To help us with our procurement effort, please indicate in your email where (ngotenders.net) you saw this tender/procurement notice.</strong></li>
</ul>
<p><strong>Sincerely</strong></p>
<p><strong>Procurement Committee</strong></p>
<h5><strong>Tender’s Files,</strong></h5>
<h5><strong><a href="https://www.ngosjobs-bids.com/index.php/submit-tender/submission-view-file/73abcfe286e504282bdac61776e50907/ec8dde28a94a8fde67c09e244f6bb8a0">5ffb04ba52a49-005-announcement.zip</a>, </strong></h5>
<hr>
<h5 dir="rtl"><strong><u>الموضوع</u></strong><strong><u>:</u></strong> <strong>فحص الطحين الغير مدعم في شمال شرق سوريا.</strong><strong> </strong></h5>
<p dir="rtl">منظمتنا و هي منظمة غير ربحية تعمل لخدمة المنكوبين في العالم و تسعى للحصول على عروض أسعار من المقاولين المؤهلين لغرض الموضوع: <strong>فحص الطحين الغير مدعم في شمال شرق سوريا.</strong> وتتوقع منظمتنا منح (عقود) متعددة أو مفردة نتيجة لهذا الطلب. وتحتفظ منظمتنا بالحق في منح التعاقد بأكثر أو أقل من المتوقع للطلب أعلاه.</p>
<p dir="rtl">لهذا الطلب. وتحتفظ منظمتنا بالحق في منح التعاقد بأكثر أو أقل من المتوقع للطلب أعلاه.</p>
<p dir="rtl"> يجب على جميع مقدمي العطاءات تقديم العروض عبر الايميل :<strong>عبر الايميل: </strong><span id="cloakc42a61e471daa10a7992dbd8b44f9b26"><a href="mailto:[email protected]"><strong>[email protected]</strong></a></span> <strong>و بصيغة</strong><strong> PDF</strong> و تم التوضيح للموضوع المناقصة بان المنظمة لا تلتزم بأي حال من الأحوال بمنح العقد كما أن المنظمة لا تلتزم بدفع أي تكاليف متكبدة في إعداد وتقديم العرض.</p>
<p dir="rtl">كما ان منظمتنا لا تتحمل أية مسؤولية عن أي أخطاء في البيانات الناتجة عن عمليات النقل أو التحويل او المحادثة.</p>
<p dir="rtl">
</p><p dir="rtl"><strong>مع فائق الاحترام و التقدير</strong></p>
<p dir="rtl"><strong>لجنة المشتريات</strong></p>
<h5><strong>Tender’s Files,</strong></h5>
<h5><strong><a href="https://www.ngosjobs-bids.com/index.php/submit-tender/submission-view-file/73abcfe286e504282bdac61776e50907/ec8dde28a94a8fde67c09e244f6bb8a0">5ffb04ba52a49-005-announcement.zip</a>, </strong></h5>
</div>
the page source code.
Upvotes: 3
Views: 1051
Reputation: 287
Your xpath should work if you add this:
//p[preceding-sibling::h5//*[contains(text() , 'SUBJECT')] and (following-sibling:: h5//*[contains(text() , 'Tender’s Files,')])[2]]
Upvotes: 1
Reputation: 111686
Using techniques from the following Q/A:
The following XPath,
//p[ preceding-sibling::h5[starts-with(normalize-space(),'SUBJECT:')]
and following-sibling::h5[normalize-space()='Tender’s Files,']]
will select all p
elements between your two targeted headlines, as requested.
Your actual markup includes duplicate
<h5><strong>Tender’s Files,</strong></h5>
headings. The above XPath will select through to the last such heading.
If you want to select through only the first such heading, use this XPath instead:
//p[ preceding-sibling::h5[starts-with(normalize-space(),'SUBJECT:')]
and following-sibling::h5[normalize-space()='Tender’s Files,']
and not(preceding-sibling::h5[normalize-space()='Tender’s Files,'])]
Upvotes: 2