Element
This is the main type of the jOOX library. It wraps an ordered list of DOM elements without duplicates and provides useful operations upon all of the contained elements. The wrapped DOM elements have been previously "matched" by a jOOX operation.
The API has been inspired by http://jquery.com, a fantastic DOM abstraction library for JavaScript.
- Author:
- Lukas Eder
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdd some elements to the set of matched elementsAdd some elements to the set of matched elementsAdd content after each element in the set of matched elements.Add content after each element in the set of matched elements.Add content after each element in the set of matched elements.Add content after each element in the set of matched elements.andSelf()
Add the previous set of matched elements to the current one.Append content to the end of each element's content in the set of matched elements.Append content to the end of each element's content in the set of matched elements.Append content to the end of each element's content in the set of matched elements.Append content to the end of each element's content in the set of matched elements.Get an attribute from the first element in the set of matched elements, ornull
if the first element does not have that attribute.<T> T
Get a converted attribute from the first element in the set of matched elements, ornull
if the first element does not have that attribute.Set an attribute on all elements in the set of matched elements.Set an attribute on all elements in the set of matched elements.Get the set of available attribute names in the set of matched elements.Get an attribute from all elements in the set of matched elements<T> List
<T> Get a converted attribute from all elements in the set of matched elementsAdd content before each element in the set of matched elements.Add content before each element in the set of matched elements.Add content before each element in the set of matched elements.Add content before each element in the set of matched elements.cdata()
Get the CDATA content of the first element in the set of matched elements, ornull
if there are no matched elements.cdata
(int index) Get the CDATA content at a given index in the current set of matched elements.<T> T
Get the converted CDATA content of the first element in the set of matched elements, ornull
if there are no matched elements.Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).cdatas()
Get all CDATA content of the elements in the set of matched elements.cdatas
(int... indexes) Get all CDATA content of the elements at given indexes in the set of matched elements.<T> List
<T> Get all converted CDATA content of the elements in the set of matched elements.child()
Find the first child of each element in the current set of matched elements.child
(int index) Find the child at a given index of each element in the current set of matched elements.Find the first matching child of each element in the current set of matched elementsFind the first matching child of each element in the current set of matched elementschildren()
Find all children of each element in the current set of matched elements.children
(int... indexes) Find all children of each element at given indexes in the current set of matched elements.Find all children of each element in the current set of matched elements.Find all children of each element in the current set of matched elements.content()
Get the XML content of the first element in the set of matched elements, ornull
if there are no matched elements.content
(int index) Get the XML content at a given index in the current set of matched elements.Add some JAXB-marshallable XML content to all elements in the set of matched elements (possibly replacing existing content).Add some XML content to all elements in the set of matched elements (possibly replacing existing content).Add some XML content to all elements in the set of matched elements (possibly replacing existing content).contents()
Get all XML content of the elements in the set of matched elements.contents
(int... indexes) Get all XML content of the elements at given indexes in the set of matched elements.copy()
Get a copy of theMatch
wrapper.document()
Get the underlying document of the set of matched elements.each()
Get all elements in the set of matched elements in a list of matches, every match representing one elementExecute several callbacks for every element in the current set of matched elements.Execute a callback for every element in the current set of matched elements.Execute several callbacks for every element in the current set of matched elements.empty()
Removes all content from all elements in the set of matched elements.eq
(int... indexes) Reduce the current set of matched elements to the elements at the given indexes.Reduce the current set of matched elements.Reduce the current set of matched elements.find()
Find all descendants of each element in the current set of matched elements.Find all descendants of each element in the current set of matched elements.Find all descendants of each element in the current set of matched elements.first()
Get the first in a set of matched elements.get()
Get an the set of matched elementsget
(int index) Get an element from the set of matched elements at a given indexget
(int... indexes) Get some elements from the set of matched elements at the given indexesReduce the set of matched element to those who have a descendant that matches a selector.Reduce the set of matched element to those who have a descendant that matches a filter.id()
Get the first id valueid
(int index) Get an id value at a given index in the current set of matched elements.<T> T
Get the first converted id valueids()
Get a list of id values in the current set of matched elements.ids
(int... indexes) Get a list of id values at given indexes in the current set of matched elements.<T> List
<T> Get a list of converted id values in the current set of matched elements.boolean
Check if at least one element in the set of matched elements satisfies a selector.boolean
Check if at least one element in the set of matched elements satisfies a filter.boolean
isEmpty()
Whether there are any matched elements in the set of matched elementsboolean
Whether there are any matched elements in the set of matched elementslast()
Get the last in a set of matched elements.leaf()
Reduce the set of matched elements to the ones that are leaf elements<E> List
<E> Map the set of matched elements to a list of somethingReduce the set of matched elements by filtering out those whose attribute content doesn't match a given regexReduce the set of matched elements by filtering out those whose attribute content doesn't match a given regex(keepMatches = true)
, or those whose text content matches a given regex(keepMatches = false)
Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regexReduce the set of matched elements by filtering out those whose tag name doesn't match a given regex(keepMatches = true)
, or those whose tag name matches a given regex(keepMatches = false)
Reduce the set of matched elements by filtering out those whose text content doesn't match a given regexReduce the set of matched elements by filtering out those whose text content doesn't match a given regex(keepMatches = true)
, or those whose text content matches a given regex(keepMatches = false)
Get a new Match with added namespace configuration for subsequent XPath callsGet the namespace prefix of the first element in the current set of matched elements.namespacePrefix
(int index) Get a namespace prefix of the element at a given index in the current set of matched elements.Get a list of namespace prefixes of the elements in the current set of matched elements.namespacePrefixes
(int... indexes) Get a list of namespace prefixes of the elements at given indexes in the current set of matched elements.namespaces
(Map<String, String> map) Get a new Match with added namespace configuration for subsequent XPath callsGet the namespace URI of the first element in the current set of matched elements.namespaceURI
(int index) Get a namespace URI of the element at a given index in the current set of matched elements.Get a list of namespace URIs of the elements in the current set of matched elements.namespaceURIs
(int... indexes) Get a list of namespace URIs of the elements at given indexes in the current set of matched elements.next()
Get the immediate next sibling of every element in set of matched elements.Get the immediate next sibling of every element in set of matched elements, matching a selectorGet the immediate next sibling of every element in set of matched elements, matching a filternextAll()
Get all next siblings of every element in a set of matched elementsGet all next siblings of every element in a set of matched elements, matching a selectorGet all next siblings of every element in a set of matched elements, matching a filterGet all next siblings of every element in a set of matched elements until the provided selector matchesGet all next siblings of every element in a set of matched elements, matching a selector, until the provided selector matchesGet all next siblings of every element in a set of matched elements, matching a filter, until the provided selector matchesGet all next siblings of every element in a set of matched elements until the provided filter matchesGet all next siblings of every element in a set of matched elements, matching a selector until the provided filter matchesGet all next siblings of every element in a set of matched elements, matching a filter until the provided filter matchesRemove elements from the set of matched elements.Remove elements from the set of matched elements.parent()
Get the immediate parent elements of every element in a set of matched elementsGet the immediate parent elements of every element in a set of matched elements, matching a selectorGet the immediate parent elements of every element in a set of matched elements, matching a filterparents()
Get all ancestor elements of every element in a set of matched elementsGet all ancestor elements of every element in a set of matched elements, matching a selectorGet all ancestor elements of every element in a set of matched elements, matching a filterparentsUntil
(String until) Get all ancestors of every element in a set of matched elements until the provided selector matchesparentsUntil
(String until, String selector) Get all ancestors of every element in a set of matched elements, matching a selector, until the provided selector matchesparentsUntil
(String until, Filter filter) Get all ancestors of every element in a set of matched elements, matching a filter, until the provided selector matchesparentsUntil
(Filter until) Get all ancestors of every element in a set of matched elements until the provided filter matchesparentsUntil
(Filter until, String selector) Get all ancestors of every element in a set of matched elements, matching a selector until the provided filter matchesparentsUntil
(Filter until, Filter filter) Get all ancestors of every element in a set of matched elements, matching a filter until the provided filter matchesPrepend content to the beginning of each element's content in the set of matched elements.Prepend content to the beginning of each element's content in the set of matched elements.Prepend content to the beginning of each element's content in the set of matched elements.Prepend content to the beginning of each element's content in the set of matched elements.prev()
Get the immediate previous sibling of every element in set of matched elements.Get the immediate previous sibling of every element in set of matched elements, matching a selectorGet the immediate previous sibling of every element in set of matched elements, matching a filterprevAll()
Get all previous siblings of every element in a set of matched elementsGet all previous siblings of every element in a set of matched elements, matching a selectorGet all previous siblings of every element in a set of matched elements, matching a filterGet all previous siblings of every element in a set of matched elements until the provided selector matchesGet all previous siblings of every element in a set of matched elements, matching a selector, until the provided selector matchesGet all previous siblings of every element in a set of matched elements, matching a filter, until the provided selector matchesGet all previous siblings of every element in a set of matched elements until the provided filter matchesGet all previous siblings of every element in a set of matched elements, matching a selector until the provided filter matchesGet all previous siblings of every element in a set of matched elements, matching a filter until the provided filter matchesremove()
Removes all elements from their parent nodes in the set of matched elements.Removes all elements from their parent nodes in the set of matched elements, matching a selectorRemoves all elements from their parent nodes in the set of matched elements, matching a filterremoveAttr
(String name) Remove an attribute from all elements in the set of matched elements.Rename all tags in the set of matched elements to some new tag nameRename all tags in the set of matched elements to some new tag namereplaceWith
(String content) Replace all elements in the set of matched elements with some new content.replaceWith
(Content content) Replace all elements in the set of matched elements with some new content.replaceWith
(Match... content) Replace all elements in the set of matched elements with some new content.replaceWith
(Element... content) Replace all elements in the set of matched elements with some new content.reverse()
Reverse the order of the set of matched elementssiblings()
Get all siblings of every element in a set of matched elementsGet all siblings of every element in a set of matched elements, matching a selectorGet all siblings of every element in a set of matched elements, matching a filterint
size()
Get the number of matched elements in the set of matched elementsslice
(int start) Reduce the set of matched elements by specifying a range of indexesslice
(int start, int end) Reduce the set of matched elements by specifying a range of indexessort
(Comparator<Element> comparator) Allows to sort the result with the given comparator.tag()
Get the tag name of the first element in the current set of matched elements.tag
(int index) Get a tag name of the element at a given index in the current set of matched elements.tags()
Get a list of tag names of the elements in the current set of matched elements.tags
(int... indexes) Get a list of tag names of the elements at given indexes in the current set of matched elements.text()
Get the text content of the first element in the set of matched elements, ornull
if there are no matched elements.text
(int index) Get the text content at a given index in the current set of matched elements.<T> T
Get the converted text content of the first element in the set of matched elements, ornull
if there are no matched elements.Set some text content to all elements in the set of matched elements (possibly replacing existing content).Set some text content to all elements in the set of matched elements (possibly replacing existing content).texts()
Get all text content of the elements in the set of matched elements.texts
(int... indexes) Get all text content of the elements at given indexes in the set of matched elements.<T> List
<T> Get all converted text content of the elements in the set of matched elements.Transform all elements in the set of matched elements.transform
(InputStream transformer) Transform all elements in the set of matched elements.Transform all elements in the set of matched elements.Transform all elements in the set of matched elements.Transform all elements in the set of matched elements.Transform all elements in the set of matched elements.transform
(Transformer transformer) Transform all elements in the set of matched elements.<T> List
<T> Unmarshal the current set of matched elements into a JAXB-annotated type.<T> List
<T> Unmarshal the current set of matched elements at given indexes into a JAXB-annotated type.<T> T
unmarshalOne
(Class<T> type) Unmarshal the first element in the current set of matched elements into a JAXB-annotated type.<T> T
unmarshalOne
(Class<T> type, int index) Unmarshal the element at a given index in the current set of matched elements into a JAXB-annotated type.unwrap()
Removes all elements in the set of matched elements from their parentsWrap all elements from their parent nodes in the set of matched elements in a new parent elementWrap all elements in the set of matched elements in a new parent elementWrite the set of matched elements into a filewrite
(OutputStream stream) Write the set of matched elements into a streamWrite the set of matched elements into a writerxpath()
Get an XPath expression describing the first element in the current set of matched elementsxpath
(int index) Get an XPath expression describing the element at a given index in the current set of matched elementsMatch all elements given a certain XPath expression applied to each element in the current set of matched elements.Match all elements given a certain XPath expression applied to each element in the current set of matched elements.xpaths()
Get a list of XPath expressions describing the elements in the current set of matched elementsxpaths
(int... indexes) Get a list of XPath expressions describing the elements at the given indexes in the current set of matched elementsMethods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
namespace
Get a new Match with added namespace configuration for subsequent XPath callsThis is a convenience method for
namespaces(java.util.Map)
- Parameters:
namespacePrefix
- A namespace prefixnamespaceURI
- A namespace URI- Returns:
- A modified
Match
- See Also:
-
namespaces
Get a new Match with added namespace configuration for subsequent XPath calls- Parameters:
map
- A mapping between prefix and namespace URI- Returns:
- A modified
Match
-
namespaceURIs
Get a list of namespace URIs of the elements in the current set of matched elements.This only works if the underlying document is namespace-aware
- See Also:
-
namespaceURIs
Get a list of namespace URIs of the elements at given indexes in the current set of matched elements.This only works if the underlying document is namespace-aware
- See Also:
-
namespaceURI
String namespaceURI()Get the namespace URI of the first element in the current set of matched elements.This is the same as calling
namespaceURI(0)
This only works if the underlying document is namespace-aware
- See Also:
-
namespaceURI
Get a namespace URI of the element at a given index in the current set of matched elements.This only works if the underlying document is namespace-aware
- See Also:
-
namespacePrefixes
Get a list of namespace prefixes of the elements in the current set of matched elements. -
namespacePrefixes
Get a list of namespace prefixes of the elements at given indexes in the current set of matched elements. -
namespacePrefix
String namespacePrefix()Get the namespace prefix of the first element in the current set of matched elements.This is the same as calling
namespaceURI(0)
-
namespacePrefix
Get a namespace prefix of the element at a given index in the current set of matched elements. -
get
Get an element from the set of matched elements at a given indexNegative indexes are possible, too.
-
-1
corresponds to the last element in the set of matched elements. -
-2
corresponds to the second-last element, etc.
-
-
document
Document document()Get the underlying document of the set of matched elements.This will also return a document if there are no elements in the set of matched elements, either because a new document has been created previously, or the set of matched elements has been reduced to an empty set.
-
get
Get some elements from the set of matched elements at the given indexesNegative indexes are possible, too.
-
-1
corresponds to the last element in the set of matched elements. -
-2
corresponds to the second-last element, etc.
-
-
get
Get an the set of matched elements -
size
int size()Get the number of matched elements in the set of matched elements -
isEmpty
boolean isEmpty()Whether there are any matched elements in the set of matched elements -
isNotEmpty
boolean isNotEmpty()Whether there are any matched elements in the set of matched elements -
add
Add some elements to the set of matched elements -
add
Add some elements to the set of matched elements -
reverse
Match reverse()Reverse the order of the set of matched elements -
andSelf
Match andSelf()Add the previous set of matched elements to the current one. This works after any of these methods (including all overloaded variants):child()
children()
find()
next()
nextAll()
nextUntil(Filter)
parent()
parents()
parentsUntil(Filter)
prev()
prevAll()
prevUntil(Filter)
siblings()
eq(int...)
, and then add the removed elements again, usingandSelf()
. -
child
Match child()Find the first child of each element in the current set of matched elements.This is the same as calling
child(0)
. -
child
Find the first matching child of each element in the current set of matched elementsThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
child
Find the first matching child of each element in the current set of matched elements -
child
Find the child at a given index of each element in the current set of matched elements. -
children
Match children()Find all children of each element in the current set of matched elements. -
children
Find all children of each element in the current set of matched elements.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
children
Find all children of each element in the current set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element whose children are searched -
Context.matchIndex()
- the index of the matched element whose children are searched -
Context.element()
- the child candidate that is being filtered -
Context.elementIndex()
- the index within its parent of the child candidate that is being filtered
-
-
children
Find all children of each element at given indexes in the current set of matched elements. -
each
Get all elements in the set of matched elements in a list of matches, every match representing one element -
each
Execute a callback for every element in the current set of matched elements. -
each
Execute several callbacks for every element in the current set of matched elements.- See Also:
-
each
Execute several callbacks for every element in the current set of matched elements.- See Also:
-
filter
Reduce the current set of matched elements.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
filter
Reduce the current set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being filtered -
Context.matchIndex()
- the index of the matched element being filtered
-
-
eq
Reduce the current set of matched elements to the elements at the given indexes. If the given indexes are not in the range of indexes, the resulting set will be empty.Negative indexes are possible, too.
-
-1
corresponds to the last element in the set of matched elements. -
-2
corresponds to the second-last element, etc.
-
-
find
Match find()Find all descendants of each element in the current set of matched elements. -
find
Find all descendants of each element in the current set of matched elements.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
Tag names are namespace-unaware. This means that existing namespaces will be ignored - CSS selectors can be used to select XML elements
using XPath (see
CSS2XPath.css2xpath(String)
)
- XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
find
Find all descendants of each element in the current set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element whose descendants are searched -
Context.matchIndex()
- the index of the matched element whose descendants are searched -
Context.element()
- the descendant candidate that is being filtered -
Context.elementIndex()
- the iteration index of the descendant candidate that is being filtered
-
-
xpath
Match all elements given a certain XPath expression applied to each element in the current set of matched elements.The XPath expression is evaluated using standard
XPath
. It must not contain any variables. Usexpath(String, Object...)
instead, if you wish to use variables. Note that only matched elements will be considered in the results. You cannot match attributes or text nodes, for instance. Examples:- Match all elements :
xpath("//*")
- Match all books :
xpath("/library/books/book")
- Match all book ID's :
xpath("//book").ids()
- Match all book names :
xpath("//book/name").texts()
- Match all book ID's :
xpath("//book/@id")
- Match all book names :
xpath("//book/name/text()")
Using jOOX with Namespaces
Namespace declarations are supported in XPath expressions. If you wish to use namespace-specific XPath elements, call
namespace(String, String)
prior toxpath(String)
Using jOOX with Xalan
If Xalan is on your classpath, jOOX will automatically load xalan's namespace and function extensions. All functionality supported by http://exslt.org will be available in your XPath expressions. Some examples:
- Match the book with the highest ID :
xpath("//book[number(@id) = math:max(//book/@id)]")
- Match books written by Orwell :
xpath("//book[java:org.joox.test.Functions.byOrwellWithNodes(.)]
- Match all elements :
-
xpath
Match all elements given a certain XPath expression applied to each element in the current set of matched elements.The XPath expression is evaluated using standard
XPath
. It may contain numerical variables, declared as$1
,$2
, etc, starting with$1
. Other variables, such as$myVar
are not supported. You must provide at least one variable in thevariables
argument for every variable index. Note that only matched elements will be considered in the results. You cannot match attributes or text nodes, for instance. Examples:- Match all elements with id greater than 5:
xpath("//*[@id > $1]", 5)
- Match all books with more than two authors and one author is
"George Orwell" :
xpath("/library/books/book[count(authors/author) > $1][authors/author[text() = $2]]", 2, "George Orwell")
- Match all book ID's :
xpath("//book/@id")
- Match all book names :
xpath("//book/name/text()")
Using jOOX with Namespaces
Namespace declarations are supported in XPath expressions. If you wish to use namespace-specific XPath elements, call
namespace(String, String)
prior toxpath(String)
Using jOOX with Xalan
If Xalan is on your classpath, jOOX will automatically load xalan's namespace and function extensions. All functionality supported by http://exslt.org will be available in your XPath expressions. Some examples:
- Match the book with the highest ID :
xpath("//book[number(@id) = math:max(//book/@id)]")
- Match books written by Orwell :
xpath("//book[java:org.joox.test.Functions.byOrwellWithNodes(.)]
- Match all elements with id greater than 5:
-
first
Match first()Get the first in a set of matched elements. -
has
Reduce the set of matched element to those who have a descendant that matches a selector.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
has
Reduce the set of matched element to those who have a descendant that matches a filter.The callback
Context
is populated like this:-
Context.match()
- the matched element whose descendants are searched -
Context.matchIndex()
- the index of the matched element whose descendants are searched -
Context.element()
- the descendant candidate that is being filtered -
Context.elementIndex()
- the iteration index of the descendant candidate that is being filtered
-
-
is
Check if at least one element in the set of matched elements satisfies a selector.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
is
Check if at least one element in the set of matched elements satisfies a filter.The callback
Context
is populated like this:-
Context.match()
- the matched element being checked -
Context.matchIndex()
- the index of the matched element being checked
-
-
last
Match last()Get the last in a set of matched elements. -
map
Map the set of matched elements to a list of something -
next
Match next()Get the immediate next sibling of every element in set of matched elements. -
next
Get the immediate next sibling of every element in set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
next
Get the immediate next sibling of every element in set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next sibling is searched -
Context.matchIndex()
- the index of the matched element whose next sibling is searched -
Context.element()
- the next sibling that is being filtered -
Context.elementIndex()
- 1
-
-
nextAll
Match nextAll()Get all next siblings of every element in a set of matched elements -
nextAll
Get all next siblings of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
nextAll
Get all next siblings of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
-
-
nextUntil
Get all next siblings of every element in a set of matched elements until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
nextUntil
Get all next siblings of every element in a set of matched elements until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
-
-
nextUntil
Get all next siblings of every element in a set of matched elements, matching a selector, until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
nextUntil
Get all next siblings of every element in a set of matched elements, matching a filter, until the provided selector matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
- See Also:
-
-
nextUntil
Get all next siblings of every element in a set of matched elements, matching a selector until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
- See Also:
-
-
nextUntil
Get all next siblings of every element in a set of matched elements, matching a filter until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose next siblings are searched -
Context.matchIndex()
- the index of the matched element whose next siblings are searched -
Context.element()
- the next siblings that is being filtered -
Context.elementIndex()
- the relative index of the next siblings that are being filtered
- See Also:
-
-
not
Remove elements from the set of matched elements.The selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
not
Remove elements from the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being checked -
Context.matchIndex()
- the index of the matched element being checked
-
-
parent
Match parent()Get the immediate parent elements of every element in a set of matched elements -
parent
Get the immediate parent elements of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
parent
Get the immediate parent elements of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parent is searched -
Context.matchIndex()
- the index of the matched element whose parent is searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- 1
-
-
parents
Match parents()Get all ancestor elements of every element in a set of matched elements -
parents
Get all ancestor elements of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
parents
Get all ancestor elements of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
-
-
parentsUntil
Get all ancestors of every element in a set of matched elements until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
parentsUntil
Get all ancestors of every element in a set of matched elements until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
-
-
parentsUntil
Get all ancestors of every element in a set of matched elements, matching a selector, until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
parentsUntil
Get all ancestors of every element in a set of matched elements, matching a filter, until the provided selector matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
- See Also:
-
-
parentsUntil
Get all ancestors of every element in a set of matched elements, matching a selector until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
- See Also:
-
-
parentsUntil
Get all ancestors of every element in a set of matched elements, matching a filter until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose parents are searched -
Context.matchIndex()
- the index of the matched element whose parents are searched -
Context.element()
- the parent that is being filtered -
Context.elementIndex()
- the relative index of the parent that is being filtered
-
-
prev
Match prev()Get the immediate previous sibling of every element in set of matched elements. -
prev
Get the immediate previous sibling of every element in set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
prev
Get the immediate previous sibling of every element in set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous sibling is searched -
Context.matchIndex()
- the index of the matched element whose previous sibling is searched -
Context.element()
- the previous sibling that is being filtered -
Context.elementIndex()
- 1
-
-
prevAll
Match prevAll()Get all previous siblings of every element in a set of matched elements -
prevAll
Get all previous siblings of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
prevAll
Get all previous siblings of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
-
-
prevUntil
Get all previous siblings of every element in a set of matched elements until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
prevUntil
Get all previous siblings of every element in a set of matched elements until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
-
-
prevUntil
Get all previous siblings of every element in a set of matched elements, matching a selector, until the provided selector matchesThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
prevUntil
Get all previous siblings of every element in a set of matched elements, matching a filter, until the provided selector matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
- See Also:
-
-
prevUntil
Get all previous siblings of every element in a set of matched elements, matching a selector until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
- See Also:
-
-
prevUntil
Get all previous siblings of every element in a set of matched elements, matching a filter until the provided filter matchesThe callback
Context
is populated like this:-
Context.match()
- the matched element whose previous siblings are searched -
Context.matchIndex()
- the index of the matched element whose previous siblings are searched -
Context.element()
- the previous siblings that is being filtered -
Context.elementIndex()
- the relative index of the previous siblings that are being filtered
-
-
siblings
Match siblings()Get all siblings of every element in a set of matched elements -
siblings
Get all siblings of every element in a set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
siblings
Get all siblings of every element in a set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element whose siblings are searched -
Context.matchIndex()
- the index of the matched element whose siblings are searched -
Context.element()
- the sibling that is being filtered -
Context.elementIndex()
- the relative index of the sibling that is being filtered. This is less than zero if it is a previous sibling or more than zero if it is a subsequent sibling, compared to the element inContext.match()
-
-
slice
Reduce the set of matched elements by specifying a range of indexesThis is the same as calling
slice(start, Integer.MAX_VALUE)
-
slice
Reduce the set of matched elements by specifying a range of indexes -
matchText
Reduce the set of matched elements by filtering out those whose text content doesn't match a given regexThis is the same as calling
matchText(regex, true)
- See Also:
-
matchText
Reduce the set of matched elements by filtering out those whose text content doesn't match a given regex(keepMatches = true)
, or those whose text content matches a given regex(keepMatches = false)
- See Also:
-
matchAttr
Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regexThis is the same as calling
matchAttr(name, valueRegex, true)
- See Also:
-
matchAttr
Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regex(keepMatches = true)
, or those whose text content matches a given regex(keepMatches = false)
- See Also:
-
matchTag
Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regexThis is the same as calling
matchText(regex, true)
- See Also:
-
matchTag
Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regex(keepMatches = true)
, or those whose tag name matches a given regex(keepMatches = false)
- See Also:
-
leaf
Match leaf()Reduce the set of matched elements to the ones that are leaf elements- See Also:
-
before
Add content before each element in the set of matched elements. -
before
Add content before each element in the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being prepended before -
Context.matchIndex()
- the index of the matched element being prepended before
-
-
before
Add content before each element in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
before
Add content before each element in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
after
Add content after each element in the set of matched elements. -
after
Add content after each element in the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being appended after -
Context.matchIndex()
- the index of the matched element being appended after
-
-
after
Add content after each element in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
after
Add content after each element in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
prepend
Prepend content to the beginning of each element's content in the set of matched elements. -
prepend
Prepend content to the beginning of each element's content in the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being prepended to -
Context.matchIndex()
- the index of the matched element being prepended to
-
-
prepend
Prepend content to the beginning of each element's content in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
prepend
Prepend content to the beginning of each element's content in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
append
Append content to the end of each element's content in the set of matched elements. -
append
Append content to the end of each element's content in the set of matched elements.The callback
Context
is populated like this:-
Context.match()
- the matched element being appended to -
Context.matchIndex()
- the index of the matched element being appended to
-
-
append
Append content to the end of each element's content in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
append
Append content to the end of each element's content in the set of matched elements.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
replaceWith
Replace all elements in the set of matched elements with some new content. -
replaceWith
Replace all elements in the set of matched elements with some new content. -
replaceWith
Replace all elements in the set of matched elements with some new content.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
replaceWith
Replace all elements in the set of matched elements with some new content.If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.
-
rename
Rename all tags in the set of matched elements to some new tag name -
rename
Rename all tags in the set of matched elements to some new tag name -
empty
Match empty()Removes all content from all elements in the set of matched elements. -
remove
Match remove()Removes all elements from their parent nodes in the set of matched elements. -
remove
Removes all elements from their parent nodes in the set of matched elements, matching a selectorThe selector provided to this method supports the following features:
- * can be used to select everything
- tag names can be used to select XML elements by tag
names (see
Element.getElementsByTagName(String)
. Tag names are namespace-unaware. This means that existing namespaces will be ignored
- CSS selectors cannot be used (yet) to select XML
elements from this method. Use
find(String)
instead - XPath cannot be used. Use
xpath(String)
instead - Namespaces cannot be used. Use
xpath(String)
withnamespaces(Map)
instead
- See Also:
-
remove
Removes all elements from their parent nodes in the set of matched elements, matching a filterThe callback
Context
is populated like this:-
Context.match()
- the matched element being removed -
Context.matchIndex()
- the index of the matched element being removed
-
-
wrap
Wrap all elements from their parent nodes in the set of matched elements in a new parent elementThe resulting set of matched elements contains the newly wrapped elements
- See Also:
-
wrap
Wrap all elements in the set of matched elements in a new parent elementThe resulting set of matched elements contains the newly wrapped elements
- See Also:
-
unwrap
Match unwrap()Removes all elements in the set of matched elements from their parentsThe resulting set of matched elements contains the newly unwrapped elements
- See Also:
-
attrNames
Get the set of available attribute names in the set of matched elements. -
attr
Get an attribute from the first element in the set of matched elements, ornull
if the first element does not have that attribute.jOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.
-
attr
Get a converted attribute from the first element in the set of matched elements, ornull
if the first element does not have that attribute.jOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.
- See Also:
-
attrs
Get an attribute from all elements in the set of matched elementsjOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.
-
attrs
Get a converted attribute from all elements in the set of matched elementsjOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.
- See Also:
-
attr
Set an attribute on all elements in the set of matched elements. Ifvalue
is null, then the attribute is removed. If the attribute already exists, then it is replaced. -
attr
Set an attribute on all elements in the set of matched elements. Ifvalue
returns null, then the attribute is removed. If the attribute already exists, then it is replaced.The callback
Context
is populated like this:-
Context.match()
- the matched element being attributed -
Context.matchIndex()
- the index of the matched element being attributed
-
-
removeAttr
Remove an attribute from all elements in the set of matched elements. This is the same as callingattr(name, null)
. -
contents
Get all XML content of the elements in the set of matched elements. -
contents
Get all XML content of the elements at given indexes in the set of matched elements. -
content
String content()Get the XML content of the first element in the set of matched elements, ornull
if there are no matched elements.This is the same as calling
content(0)
-
content
Get the XML content at a given index in the current set of matched elements. -
content
Add some XML content to all elements in the set of matched elements (possibly replacing existing content). If the supplied content is invalid XML or plain text, then it will be added as text just as withtext(String)
-
content
Add some JAXB-marshallable XML content to all elements in the set of matched elements (possibly replacing existing content).- See Also:
-
content
Add some XML content to all elements in the set of matched elements (possibly replacing existing content). If the supplied content is invalid XML or plain text, then it will be added as text just as withtext(String)
The callback
Context
is populated like this:-
Context.match()
- the matched element being added to -
Context.matchIndex()
- the index of the matched element being added to
-
-
texts
Get all text content of the elements in the set of matched elements. -
texts
Get all converted text content of the elements in the set of matched elements.- See Also:
-
texts
Get all text content of the elements at given indexes in the set of matched elements. -
text
String text()Get the text content of the first element in the set of matched elements, ornull
if there are no matched elements.This is the same as calling
text(0)
-
text
Get the converted text content of the first element in the set of matched elements, ornull
if there are no matched elements.- See Also:
-
text
Get the text content at a given index in the current set of matched elements. -
text
Set some text content to all elements in the set of matched elements (possibly replacing existing content). -
text
Set some text content to all elements in the set of matched elements (possibly replacing existing content).The callback
Context
is populated like this:-
Context.match()
- the matched element being added to -
Context.matchIndex()
- the index of the matched element being added to
-
-
cdatas
Get all CDATA content of the elements in the set of matched elements.This is the same as
texts()
. -
cdatas
Get all converted CDATA content of the elements in the set of matched elements.This is the same as
texts(Class)
.- See Also:
-
cdatas
Get all CDATA content of the elements at given indexes in the set of matched elements.This is the same as
texts(int...)
. -
cdata
String cdata()Get the CDATA content of the first element in the set of matched elements, ornull
if there are no matched elements.This is the same as calling
cdata(0)
ortext()
. -
cdata
Get the converted CDATA content of the first element in the set of matched elements, ornull
if there are no matched elements.This is the same as
text(Class)
.- See Also:
-
cdata
Get the CDATA content at a given index in the current set of matched elements.This is the same as
text(int)
. -
cdata
Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).Unlike
text(Content)
, this generates aNode.CDATA_SECTION_NODE
. -
cdata
Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).The callback
Context
is populated like this:Context.match()
- the matched element being added toContext.matchIndex()
- the index of the matched element being added to
Unlike
text(Content)
, this generates aNode.CDATA_SECTION_NODE
. -
copy
Match copy() -
xpaths
Get a list of XPath expressions describing the elements in the current set of matched elements -
xpaths
Get a list of XPath expressions describing the elements at the given indexes in the current set of matched elements -
xpath
String xpath()Get an XPath expression describing the first element in the current set of matched elementsThis is the same as calling
xpath(0)
-
xpath
Get an XPath expression describing the element at a given index in the current set of matched elements -
tags
Get a list of tag names of the elements in the current set of matched elements. -
tags
Get a list of tag names of the elements at given indexes in the current set of matched elements. -
tag
String tag()Get the tag name of the first element in the current set of matched elements.This is the same as calling
tag(0)
-
tag
Get a tag name of the element at a given index in the current set of matched elements. -
ids
Get a list of id values in the current set of matched elements.This is the same as calling
attrs("id")
-
ids
Get a list of id values at given indexes in the current set of matched elements. -
ids
Get a list of converted id values in the current set of matched elements.- See Also:
-
id
String id()Get the first id valueThis is the same as calling
id(0)
-
id
Get an id value at a given index in the current set of matched elements.This is the same as calling
eq(index).attr("id")
-
id
Get the first converted id value- See Also:
-
write
Write the set of matched elements into a writerIf the set contains more or less than
1
element, this will result in writing non-well-formed XML- Throws:
IOException
-
write
Write the set of matched elements into a streamIf the set contains more or less than
1
element, this will result in writing non-well-formed XML- Throws:
IOException
-
write
Write the set of matched elements into a fileIf the set contains more or less than
1
element, this will result in writing non-well-formed XML- Throws:
IOException
-
unmarshal
Unmarshal the current set of matched elements into a JAXB-annotated type. -
unmarshal
Unmarshal the current set of matched elements at given indexes into a JAXB-annotated type. -
unmarshalOne
Unmarshal the first element in the current set of matched elements into a JAXB-annotated type.This is the same as calling
unmarshalOne(type, 0)
-
unmarshalOne
Unmarshal the element at a given index in the current set of matched elements into a JAXB-annotated type.This is the same as calling
unmarshalOne(type, 0)
-
transform
Transform all elements in the set of matched elements.This will apply a given
Transformer
to every element in the set of matched elements. Every element in the set of matched elements will be replaced by its correspondingResult
obtained from thetransformer
.Example Input:
<books> <book id="1"/> <book id="2"/> </books>
Example XSLT:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="book"> <book id=""> <xsl:apply-templates/> </book> </xsl:template> <xsl:template match="@*|*"> <xsl:copy> <xsl:apply-templates select="*|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
Apply transformation:
// Applies transformation to the document element: $(document).transform("increment.xsl"); // Applies transformation to every book element: $(document).find("book").transform("increment.xsl");
Result:
<books> <book id="2"/> <book id="3"/> </books>
-
transform
Transform all elements in the set of matched elements.- See Also:
-
transform
Transform all elements in the set of matched elements.- See Also:
-
transform
Transform all elements in the set of matched elements.- See Also:
-
transform
Transform all elements in the set of matched elements.- See Also:
-
transform
Transform all elements in the set of matched elements.- See Also:
-
transform
Transform all elements in the set of matched elements.- See Also:
-
sort
Allows to sort the result with the given comparator.- Parameters:
comparator
- The element comparator.- Returns:
-