groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garneke <>
Subject XmlSlurper Namespace Question
Date Mon, 11 Apr 2016 16:40:51 GMT
I have a requirement in my application to receive xml files from a user and
filter out specific nodes based on a configuration option ( accepts GPath
String ).

This is fine.  
I can use XmlSlurper to parse the file and with the defined GPath I can find
and remove the node and rewrite the file.

My application is generic and can accept any XML.  
My user base is not terribly savvy so I need to be able to have the GPath
specified without the namespace prefixes.   This is also fine if the
XmlSlurper is created to be namespace aware.

*The problem is...*
If my XmlSlurper is namespace aware and I remove a node, when I re-write the
XML file all of the namespace prefixes get altered to "tag0:", "tag1:",
"tag2:" etc.

Is there a way to produce the XML with its original namespace prefixes?
Is there someway I can query the original file for its namespaces and use
that declare the namespaces for the slurper?

Thanks in advance for your help.

View this message in context:
Sent from the Groovy Users mailing list archive at

View raw message