public class DomQuery extends Object
Provides high performance selector/xpath processing.
DomQuery supports most of the CSS3 selectors spec, along with some custom selectors and basic XPath.
All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example "div.foo:nth-child(odd)[@foo=bar].bar:first" would be a perfectly valid selector. Node filters are processed in the order in which they appear, which allows you to optimize your queries for your document structure.
The use of '@' and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.
Constructor and Description |
---|
DomQuery() |
Modifier and Type | Method and Description |
---|---|
static Element[] |
filter(Element[] elems,
String selector,
boolean nonMatches)
Filters an array of elements to only include matches of a simple selector
(e.g.
|
static boolean |
is(Element elem,
String selector)
Returns true if the passed element(s) match the passed simple selector
(e.g.
|
static <any> |
select(String selector)
Selects a group of elements using the document as the root node.
|
static <any> |
select(String selector,
Element root)
Selects a group of elements.
|
static Element |
selectNode(String selector)
Selects a single element using the document as the root node.
|
static Element |
selectNode(String selector,
Element root)
Selects a single element using the given root node.
|
static String |
selectValue(String selector,
Element root)
Selects the value of a node,
|
static String |
selectValue(String selector,
JavaScriptObject root)
Selects the value of a node,
|
public static Element[] filter(Element[] elems, String selector, boolean nonMatches)
elems
- an array of elementsselector
- the selector/xpath querynonMatches
- if true, it returns the elements that DON'T match the
selector instead of the ones that matchpublic static boolean is(Element elem, String selector)
elem
- the elementselector
- The selector/xpath query (can be a comma separated list of
selectors)public static <any> select(String selector)
selector
- the selector/xpath querypublic static <any> select(String selector, Element root)
selector
- the selector/xpath queryroot
- the start of the querypublic static Element selectNode(String selector)
selector
- the selector/xpath querypublic static Element selectNode(String selector, Element root)
selector
- the selector / xpath queryroot
- the start of the querypublic static String selectValue(String selector, Element root)
selector
- the selector/xpath queryroot
- the start of the queryCopyright © 2018. All rights reserved.