The situation:
def str = """
<foo xmlns:weird="http://localhost/">
<bar>sudo </bar>
<weird:bar>make me a sandwich!</weird:bar>
</foo>
"""
def xml = new XmlSlurper().parseText(str)
println xml.bar
The output of this snippet is
# sudo make me a sandwich!
It seems like the parser merges the contents of <bar>
and <weird:bar>
.
Is this behavior desired and if yes, how can I avoid this and select only <bar>
or <weird:bar>
?
println xml.':bar'
apart from parsing the root element for namespaces and declaring them? – Endaendall