0

Let suppose I have this html body

<div style="height: 100%">
  <div class="vtex-rich-text-0-x-container">
    <div class="vtex-rich-text-0-x-wrapper">
      <p class="lh-copy vtex-rich-text-0-x-paragraph">
        <span class="b vtex-rich-text-0-x-strong">
Payless Shoesource Customer Care
</span>
        <br> 4910 Corporate Centre Dr, Suite 210<br> Lawrence, KS 66047<br> Customer.service@payless.com
      </p>
    </div>
  </div>
</div>

And someone has given me a text from the above html for eg: Lawrence I want to find the nearest html tag in which this Lawrence is present,which is <p> tag in our case and the content of that p tag. which is <span class="b vtex-rich-text-0-x-strong">Payless Shoesource Customer Care</span><br> 4910 Corporate Centre Dr, Suite 210<br> Lawrence, KS 66047<br> Customer.service@payless.com

Paulie_D
  • 107,962
  • 13
  • 142
  • 161
  • 1
    The content of the tag does not include the end tag ``. Have you done any research into the subject, and made any attempts based on that research? – Heretic Monkey Sep 29 '20 at 14:56
  • 1
    Does this answer your question? [Find parent element of string in Javascript](https://stackoverflow.com/questions/50597213/find-parent-element-of-string-in-javascript) – Tasos Sep 29 '20 at 14:59
  • Seems like duplicate to this: https://stackoverflow.com/a/50597853/5605822 – Tasos Sep 29 '20 at 14:59
  • *"someone has given me a text"* How was it given? What is the input you get? – epascarello Sep 29 '20 at 15:00
  • I am working with java so cannot use jquery in it. I am crawling the website and getting the html body out of it and then looking for some countries and state using NER and where I got the match I will try to look for parent tag of that text. So is there any way to do this without using jquery. – Ankush Shukla Sep 29 '20 at 15:11
  • This question is incorrectly closed because the answer doesn't solve this problem and has nothing to do with Jsoup used here, which is a Java library, not JavaScript! Correct answer is: `doc.selectFirst(":containsOwn(Lawrence)")` – Krystian G Sep 29 '20 at 23:55

0 Answers0