I got a html file like this:
<!document>
<!--
<html>
<head>
<title>TEST</title>
</head>
<body>
<!--
<span>hello and cut the site</span>
<div>
<header>
<div>
<!--
<span>header here!</span>
</div>
</header>
</div>
<p> This is 123</p>
<content >
<!--
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
</content>
<p> This is 345</p>
<div>
<!--
<footer><!--
<div>footer here</div></footer>
</div>
<br/>
<h2>hahaha</h2>
</body>
</html>
With Jsoup, i got
<div>
tag, which before my <content> tag; and
<div>
tags, which are before/after
<content>
tag as arguments in my function:
private void extractPage(Element previousTag,Element nextTag)throws IOException
{
Document doc = getDocHTML("product.html");
String str=previousTag.tagName()+"~*";
Elements rs= doc.select(str);
String str2=nextTag.tagName()+"~*";
Elements rs2=rs.select(str2).remove();
this.messager.show(rs.outerHtml());
}
I want to extract everything between my 2 previousTag and nextTag.
But with my function, i can't do it now.
I want to get result as this :
<p> This is 123</p>
<content >
<!--
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
</content>
<p> This is 345</p>
Please help me.