tagName = tagName.replace("|", ":");
return root.getElementsByTag(tagName);
}
private Elements byAttribute() {
TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue
String key = cq.consumeToAny("=", "!=", "^=", "$=", "*=", "~="); // eq, not, start, end, contain, match, (no val)
Validate.notEmpty(key);
cq.consumeWhitespace();
if (cq.isEmpty()) {
return key.startsWith("^") ? root.getElementsByAttributeStarting(key.substring(1)) : root.getElementsByAttribute(key);
} else {
if (cq.matchChomp("="))
return root.getElementsByAttributeValue(key, cq.remainder());
else if (cq.matchChomp("!="))
return root.getElementsByAttributeValueNot(key, cq.remainder());
else if (cq.matchChomp("^="))
return root.getElementsByAttributeValueStarting(key, cq.remainder());
else if (cq.matchChomp("$="))
return root.getElementsByAttributeValueEnding(key, cq.remainder());
else if (cq.matchChomp("*="))
return root.getElementsByAttributeValueContaining(key, cq.remainder());
else if (cq.matchChomp("~="))
return root.getElementsByAttributeValueMatching(key, cq.remainder());
else
throw new SelectorParseException("Could not parse attribute query '%s': unexpected token at '%s'", query, cq.remainder());
}
}