xml - Groovy XmlSlurper with special characters in node names -


i trying use groovy xml slurper slurp following xml, goal being getting the:

<message>aroute</message>  

tag.

<org.kie.server.api.model.serviceresponse> <type>success</type> <msg>container container2 called.</msg> <result class="string">     <execution-results>     <result identifier="helloworld"> <com.me.testproject.helloworld>   <message>aroute</message> </com.me.testproject.helloworld> </result> <fact-handle identifier="helloworld" external-form="0:1:1985641387:1985641387:2:default:non_trait:com.me.testproject.helloworld"/> </execution-results></result> </org.kie.server.api.model.serviceresponse> 

when use following gpath:

def response = new xmlslurper().parsetext(payload) def result = response.result println( "output " + result) 

i following (which expect)

output <execution-results>  <result identifier="helloworld"> <com.me.testproject.helloworld>   <message>aroute</message> </com.me.testproject.helloworld> </result> <fact-handle identifier="helloworld" external-  form="0:37:1288414012:1288414012:74:default:non_trait:com.me.testproject.helloworld"/> </execution-results> 

however when attempt parse execution-results appears off, understanding becuase of hyphon in xml node name, should put in characters doesnt seem trick:

def response = new xmlslurper().parsetext(payload) def result = response.result.'execution-results' println( "the type " + result) 

outputs: type

how go drilling deeper xml message message tag?

by default, tostring() of gpath expression equivalent text() method: show text content of nodes matched expression. in short: expression has worked, println didn't show expected.

if wants content xml, can use groovy.xml.xmlutil.serialize(result)


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -