* @param attrName name of attribute filter.
* @param attrContains expected content for attribute.
* @return
*/
private static List<Node> findAllBy(Node root, final String tagName, final String attrName, String attrContains) {
DocumentTraversal documentTraversal = (DocumentTraversal) root.getOwnerDocument();
if (documentTraversal == null) {
documentTraversal = (DocumentTraversal) root;
}
final Pattern attrContainsPattern;
if (attrContains != null && !attrContains.equals("*")) {
attrContainsPattern = Pattern.compile("(^|\\s)" + attrContains + "(\\s|$)", Pattern.CASE_INSENSITIVE);
} else {
attrContainsPattern = null;
}
final List<Node> result = new ArrayList<Node>();
NodeIterator nodeIterator = documentTraversal.createNodeIterator(
root,
NodeFilter.SHOW_ELEMENT,
new NodeFilter() {
@Override
public short acceptNode(Node node) {