jQuery-like selector for Jericho HTML Parser.
Jericho is a great library for parsing and manipulating HTML. But it lacks selectors.
Yes, we have jsoup that has selectors, but there are differences between the projects.
For instance, Jericho allows you to modify just an excerpt of the HTML (keeping formatting and white spaces), while jsoup rewrite the entire structure. It happens because Jericho regards about each character in the document.
And even if I had not any other reason, I just like options. Let each library shine in their own way. ;)
Just add the following dependency:
<dependency>
<groupId>br.com.starcode.jerichoselector</groupId>
<artifactId>jericho-selector</artifactId>
<version>1.0.1-RELEASE</version>
</dependency>
Import the static method $
that is used as the entry point:
import static br.com.starcode.jerichoselector.jerQuery.$;
Then you can query HTML elements just like jQuery:
$(html, "p.my-text")
This method is overloaded several times, so you have a lot of input optionsL. Have a look at the unit test to see complete examples.
- CSS3 Selector parser library based on W3C Official Specification
- Status: DONE
- Element selector implementation using Jericho HTML Parser and the parser from step
- STATUS: DONE
- Improve performance of specific selectors (shortcuts)
- Transversing methods (partially implemented)
- jQuery extended features
- DOM manipulation
- Attributes handling
val()
each()
(allow lambda expressions),index()
,length()
,selector()
,contains()
,grep
Please, fell free to tell me if you have any issue, suggestion, contribution, or comment. ;)
Just go to http://luizricardo.org.