Forum Discussion

Oct21's avatar
Oct21
Occasional Contributor
6 years ago

Getting error "content is not allowed in prolog" while parsing XML through groovy scripts

Hi  Am using groovy script to parse the XML. Am able get all the data nodes but not able to fetch the particular which i want. Code  assert context.response def getData = { data, element -> ...
  • nmrao's avatar
    nmrao
    6 years ago

    Oct21 ,

     

    Here is the new script assertion for the attached xml

     

     

    assert context.response
    
    def getData = { data, element ->
    	new XmlSlurper().parseText(data).'**'.find {it.name() == element}
    }
    
    
    def receiptId = getData(context.response, 'ReceiptId')
    log.info receiptId
    context.testCase.setPropertyValue('ID', receiptId.toString())