Forum Discussion

vitsvg's avatar
vitsvg
Occasional Contributor
15 years ago

how to extract xml fragment

Hi there,

How I can extract not the value of a node but its xml?

So if I have xml like this:


 
    123
 



then I would like to get

 
    123
 


by specifying X-Path "a/b" or "//b".

Can I use XmlHolder (from com.eviware.soapui.support.GroovyUtils) for the purpose?

2 Replies

  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    For example, if you have your XML in a Properties step in a property named xml, then in a Groovy script step you can do:

    def xmlFragment = context.expand('${Properties#xml#//b}')


    then xmlFragment will contain

    <b>
        <c>123</c>
    </b>