shubhimu
7 years agoContributor
Groovy Method to find out whether XML response has namespace in it or not
Hi,
Can anyone help me with the method to find out whether XML response has namespace in it or not. ?
Actually i want to achieve below:
If name space exist in response then i will set t...
- 7 years ago
Hi,
you would use XmlSlurper to parse xml.Hi,
you would use XmlSlurper to parse xml. like below:
// xmlResponse
def rootNode = new XmlSlurper().parseText(xmlResponse)
def gpathClass = rootNode.getClass().getSuperclass()
def namespace = gpathClass.getDeclaredField("namespaceTagHints")
namespace.setAccessible(true)
def namespaceDeclaration = namespace.get(rootNode)
log.info namespaceDeclaration