java - Jsoup select excluding Elements with :not, not getting expected text -
i'm trying text isn't in span or in class _21ok _50f5
, in case want no text @ all, keep getting text.
i tried combinations of select(._42ef:not(._21ok._50f5))
, , select(._42ef).not(._21ok._50f5)
, more , still text.
<div class="_42ef"> <div class="_6a _5u5j"> <div class="_6a _6b" style="height:36px"></div> <div class="_6a _5u5j _6b"> <div class=""> <span class="_21ok _50f5">add current city</span> <span class="img _55ym _55yn _55yo _5tqs _3-9a" aria-label="loading..." aria-busy="1"></span> </div> </div> </div> </div>
anyone knows problem or how fix it?
i think there several reasons why not performing had hoped. here example of javascript/jquery works. hope helps:
//look in elements of root , specify each filter criteria separately $('._42ef').find('*').not('span, ._21ok, ._50f5').each(function() { //only immediate text var directtext = $(this).clone() .children() .remove() .end() .text().trim(); //only add if text has value (and not whitespace) if (directtext) texts.push(directtext); });
i prepared jsfiddle help: https://jsfiddle.net/038o91ec/
Comments
Post a Comment