public class MultiLevelByNameAndTextSelector extends Object implements ElementSelector
ElementSelector that allows two elements to be compared if
their name (including namespace URI, if any) and textual content is
the same at a certain level of nesting.
This means ElementSelectors.byNameAndText and MultiLevelByNameAndTextSelector(1) should lead to the same
results.
Any attribute values are completely ignored. Only works on elements with exactly one child element at each level.
This class mostly exists as an example for custom
ElementSelectors and may need to be combined inside a conditionalSelector in order
to be useful for the document as a whole.
| Constructor and Description |
|---|
MultiLevelByNameAndTextSelector(int levels)
Uses element names and the text nested
levels child
elements deeper into the element to compare elements. |
MultiLevelByNameAndTextSelector(int levels,
boolean ignoreEmptyTexts)
Uses element names and the text nested
levels child
elements deeper into the element to compare elements. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canBeCompared(Element controlElement,
Element testElement)
Determine whether the two elements from the control and test
XML can be compared.
|
public MultiLevelByNameAndTextSelector(int levels)
levels child
elements deeper into the element to compare elements.
Does not ignore empty text nodes.
levels - level of nesting to use when looking up the textpublic MultiLevelByNameAndTextSelector(int levels,
boolean ignoreEmptyTexts)
levels child
elements deeper into the element to compare elements.levels - level of nesting to use when looking up the textignoreEmptyTexts - whether whitespace-only textnodes
should be ignored.public boolean canBeCompared(Element controlElement, Element testElement)
ElementSelectorcanBeCompared in interface ElementSelectorcontrolElement - element of the control XMLtestElement - element of the test XMLCopyright © 2001–2025 XMLUnit. All rights reserved.