The Play Framework provides a great XPath object for processing XML documents. For example, to select foobar
nodes from an xml document you could use
List<Node> nodes = XPath.selectNodes(".//foobar", xmlDocument);
However, this is case sensitive (as expected), so if you were to run the same query on an xml document that had the elements named fooBar
instead, then no nodes would be found.
Through my google searches I found that "case-insensitive" searching can be achieved by making the node name lower case:
.//[lower-case(@foobar)]
Does anyone know how I would apply that to work with the Play Framework's XPath lib?
I don't know what Play, specifically, supports, but you have a couple options. First, if Play supports XPath 2.0, then use lower-case
:
//*[lower-case(local-name())='foo']
If lower-case
is not supported, then use the XPath 1.0 translate
function to imitate it:
//*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz')='foo']