xmlText() not working (like htmlText())

Given this GREL expression:


I get this result:

 "Intendencia de Veracruz"

But, trying to strip away the tags, this expression:


Results in error:

Error: xmlText failed as the first parameter is not an XML or HTML Element. Please first use parseXml() or parseHtml() and select(query) prior to using this function

No fair! Shouldn't xmlText() work just like htmlText(), resulting in just what's inside the tags?

Advice appreciated,


Hi Mark,

select() returns an array, so the fix is simple - just index the first element of the array returned, ie


The .toString() is unnecessary since you're already being returned a string.


p.s. it's easier for people to help you if you include all the data necessary to reproduce your example.
pps I suppose your first example could be made to return '[ "Intendencia de Veracruz"]" but I suspect that, on balance, it would make more users unhappier.

1 Like

Thanks, Tom,

"select() returns an array". I missed this in the documentation, but sure enough there it is, right on the screen. Thanks for pointing out.

Everything working and all is well!

Much appreciated,