I am using JSOUP library to parse the html.But I was ending up having extra closing tags with encoded <>(< and >) added up in my DOM.Hence I used the String utils library to get rid of that encoded stuff.Hence I still have duplicate closing tags but they are not encoded. So my initial html is
<!DOCTYPE html>
<html xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" class="SAF" id="global-header-light">
<head>
</head>
<body>
<div style="background-image: url(http://aka-cdn-ns.adtech.de/rm/ads/23274/HPWomenLOFT_1381687318.jpg);background-repeat: no-repeat;-webkit-background-size: 1001px 2059px; height: 2059px; width: 1001px; text-align: center; margin: 0 auto;">
<div style="height:2058px; padding-left:0px; padding-top:36px;">
<iframe style="height:90px; width:728px;" />
</div>
</div>
</body>
</html>
And after getiing it through this code
String url = request.getParameter("htmluri").trim();
System.out.println("Fetching %s..."+url);
Document doc = Jsoup.connect(url).get();
//System.out.println(doc.html());
Document.OutputSettings settings = doc.outputSettings();
settings.prettyPrint(false);
//settings.escapeMode(Entities.EscapeMode.base);
settings.charset("ASCII");
String html = doc.html();
html = StringEscapeUtils.unescapeHtml(html);
System.out.println(html);
// String html = doc.html();
System.out.println(html);
I get this html
<!DOCTYPE html><html xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" class="SAF" id="global-header-light"><head>
</head>
<body>
<div style="background-image: url(aol.jpeg);background-repeat: no-repeat;-webkit-background-size:100720; height:720; width:100; text-align: center; margin: 0 auto;">
<div style="height:100; padding-left:0px; padding-top:36px;">
<iframe style="height:90px; width:728px;"></iframe>
</div>
</div>
</body>
</html></div></div></body></html>
So there are additional duplicate closing div body and html tags.Though they dont harm the rendering of page I guess.Is there a way to get rid of it.
Thanks Swaraj