java - How to fetch all the header elements of a parsed HTML using Jsoup? -


this question has answer here:

i working on project using jsoup api's parse html. in module, receive htmldom object of document class , trying header elements. want extract elements header type <h1, h2, ..., h6>

i tried going through jsoup api, , in that, methods elements class, couldn't find methods extracts me header elements.

please guide me if there exists methods can simplify current code extracting header elements elements collection using jsoup.

elements elementsobj = htmldom.getallelements(); (element htmlelement : elementsobj) {     // match , extract headers other elements     if (htmlelement.nodename().matches("h[1-6]")) {         headernodelist.add(htmlelement);     } 

what avoid looping use jsoup's select method. allows select elements directly document , avoids iteration. here stack overflow post same question jsoup: heading tags


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -