Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select Element with empty class using Jsoup

Tags:

java

jsoup

I want to select the element with class="" like

<li class="" > </li>

I used

Elements topProductSecNav = topNavWrapper.select("li[class=]");

but I got java.lang.IllegalArgumentException: String must not be empty exception.

like image 844
Manojkumar Avatar asked Sep 11 '15 06:09

Manojkumar


People also ask

Can we use XPath in jsoup?

With XPath expressions it is able to select the elements within the HTML using Jsoup as HTML parser.

What is jsoup element?

A HTML element consists of a tag name, attributes, and child nodes (including text nodes and other elements). From an Element, you can extract data, traverse the node graph, and manipulate the HTML.

What does jsoup parse do?

jsoup can parse HTML files, input streams, URLs, or even strings. It eases data extraction from HTML by offering Document Object Model (DOM) traversal methods and CSS and jQuery-like selectors. jsoup can manipulate the content: the HTML element itself, its attributes, or its text.


1 Answers

Use this: Elements topProductSecNav=topNavWrapper.select(li[class=\"\"]");
See working example here.

like image 147
TDG Avatar answered Oct 04 '22 09:10

TDG