I have the following html:
text text
String html = " ...";
Document doc = Jsoup.parse(html);
Elements p = doc.select("div#content > p");
p.html(p.html().replaceAll("text", "word"));
System.out.println(doc.toString());
If you want to replace the text only in div#content > p
means that the elements in the element
content
.
text
: Elements p = doc.select("div#content > p > strong");
p.html(p.html().replaceAll("text", "word"));