I’m trying to parse an html document with Jsoup to get all heading tags. In addition I need to group the heading tags as [h1] [h2] etc…
hh = doc.select("h[0-6]");
but this give me an empty array.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your selector means h-Tag with attribute “0-6” here – not a regex. But you can combine multiple selectors instead:
hh = doc.select("h0, h1, h2, h3, h4, h5, h6");.Grouping: do you need a group with all h-Tags + a group for each h1, h2, … tag or only a group for each h1, h2, … tag?
Here’s an example how you can do this:
If you want a group for each h1, h2, … tag you can drop first selector and replace
hTagswithdocin the others.