Forum Discussion

shubhimu's avatar
6 years ago

How to remove namespace after parsing XML using XMLSlurper



I am using XMl Slurper for parsing XML response and using below code for the same

def xml= new XmlSlurper().parseText(response) ---response is the value coming from the response

def updatedXml= XmlUtil.serialize(xml)--have used this to show data in XML


if i am printing updatedXml then it shows namespace also but i dont want namespace after parsing.


Can any one help me here?




1 Reply

  • Radford's avatar
    Super Contributor

    I haven't actually used this, but have you looked at the XmlNodePrinter? It looks like you have to use this in conjunction with the XmlParser (not XmlSlurper), but you can see from the docs there is a setNamespaceAware method with the description "Enable and/or disable namespace handling.".


    As I said i haven't actually used this, but might be worth an investigation?