java - How to fetch all the header elements of a parsed HTML using Jsoup? -
this question has answer here:
- jsoup: heading tags 2 answers
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
Post a Comment