How to find elements by attributes in a DOM document with Java? Thanks.
Share
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.
With a utility like jOOX, you can wrap your DOM document and use a jQuery-like API to achieve what you need. You have several options:
Using XPath (of course, instead of using jOOX, you could use the standard Java XPath API directly)
Using CSS-style selectors
Using the jOOX API
The returned
org.joox.Matchobject can then be used in various ways, e.g. for iteration: