我想找到所有类为'srpCards'的节,并且不包含其src为https://exmple.com/hotelsnew/static/images/soldOut.png的特定img,我在xpath下尝试过,但都不起作用。

//section[contains(@class,'srpCards') and not(contains(.//img[@src='https://expample.com/hotelsnew/static/images/soldOut.png']))]

//section[contains(@class,'srpCards') and not(contains(@src,'https://exmple.com/hotelsnew/static/images/soldOut.png']))]


下面是html

    <section class="srpCards">
   <div class="col-md-4 col-sm-4 col-xs-12 pad0 posRel">
      </a>
      <div id="srpCarousel" class="dn"><img src="" class="width100 fl dn" height="230"></div>
      <!-- react-text: 26273 --><!-- /react-text -->
      <div class="htlTypeTags dn">
         <div class="htlTypeTagsInner">
            <span class="tagText">Family</span>
            <span class="tagText">Groups</span>
         </div>
      </div>
      <div class="shortlist dn">
         <a href="javascript:void(0);" class="fl">
         <i class="icon-heart fl ico18 outrHrt"></i>
         </a>
      </div>
   </div>
   <div class="col-md-8 col-sm-8 col-xs-12 padL15">
      <div class="width100 fl">
         <div class="col-md-12 col-sm-12 col-xs-12 pad0">
            <div class="col-md-9 col-sm-9 pad0">
               <div class="width100 fl ico20">
                  <span class="fl ico20 blue padR20 lh1-2 fmed">
                     <!-- react-text: 26288 -->Durga Guest House<!-- /react-text -->
                     <span class="dib padT5 padL15"><span class="fl padR5 ico11 grey padT2"></span>
                     </span>
                  </span>
                  </a>
                  <p class="width100 fl greyLt ico14 padT2 padB5">
                     <span class="fl padR5">
                        <!-- react-text: 26293 -->Area : <!-- /react-text --><!-- react-text: 26294 -->Wakad<!-- /react-text -->
                     </span>
                     <!-- react-text: 26295 --><!-- /react-text -->
                  </p>
                  <!-- react-text: 26296 --><!-- /react-text -->
               </div>
            </div>
            <div class="col-md-3 col-m-3 pad0 fr txtRight curPos" style="display: flex; justify-content: flex-end;">
               <div>
                  <div class="fr txtRight">
                     <i class="icon-reverse-go ico22 lh1-2 orange fl"></i>
                     <span class="ratingNum orange">
                        <span class="fb">2.5</span><!-- react-text: 26303 -->/5<!-- /react-text -->
                     </span>
                  </div>
                  <span class="fr txtRight blue ico13 padT4 marginT2 padL15">
                     <!-- react-text: 26305 -->38<!-- /react-text --><!-- react-text: 26306 --> reviews<!-- /react-text -->
                  </span>
               </div>
            </div>
         </div>
         <div class="width100 fl padT10">
            <div class="col-md-6 col-sm-6 pad0"></div>
            <!-- react-text: 26309 --><!-- /react-text -->
         </div>
         <div class="width100 fl marginT10">
            <div class="col-md-7 col-sm-7 pad0 marginB5">
               <div class="width100 fl"><span class="tooltipped tooltipped-n fl marginR15" data-tooltip-label="Room Service"><i class="icon-service2 ico24  fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Gym/Spa"><i class="icon-gym2 ico26  fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Internet Access"><i class="icon-wifi3 ico24  fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Restaurant"><i class="icon-restaurant2 ico24  fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Swimming Pool"><i class="icon-swimming2 ico26  fl blue"></i></span><span class="fl marginR15 no-highlight" data-tooltip-label="Free Internet"><i class="icon-wifi-free ico24 fl blue"></i></span></div>
               <div class="roomTypeSrp dn">
                  <div class="roomTypeSrpInner">
                     <span class=" fl width100 ico12 blue"></span>
                     <ul></ul>
                  </div>
               </div>
            </div>
            <div class="col-md-5 col-sm-5 pad0 txtRight marginB10">
               <div class="width100 fl txtRight"></div>
               <div>
                  <div class="width100 fl txtRight">
                     <p class="greyDr fr ico20 fb"><img src="https://example.com/hotelsnew/static/images/soldOut.png"></p>
                  </div>
               </div>
               <span class="width100 fr txtRight marginT5 ico12 fmed greyDr"></span>
               <div class="width100 fl txtRight  marginT10"><button class="button orange fr">Show Detail</button></div>
            </div>
            <!-- react-text: 26338 --><!-- /react-text -->
         </div>
      </div>
   </div>
</section>

最佳答案

您靠近的地方,<img>是已故者,不是<section>的一部分

//section[contains(@class,'srpCards') and not(//img[contains(@src,'https://example.com/hotelsnew/static/images/soldOut.png')])]

08-28 18:53