Forum Discussion

DavidACollier's avatar
DavidACollier
New Contributor
9 years ago
Solved

Property Transfer with xpath of element based on child element

Hi, I'm attempting a property transfer in SoapUI NG, based on the XPath however it is not working for me. 

 

Taking this example response: 

 

<e>
    <id>f34f9f76-a4d9-412d-8407-f08299595f2a</id>
    <name>IronMan</name>
    <rank>1</rank>
</e>
<e>
    <id>a97f6768-d087-4993-9a48-1a20ae23d27f</id>
    <name>Thor</name>
    <rank>2</rank>
</e>
<e>
    <id>a0cf6c6e-31e3-4f28-98ec-33ae0d665e5d</id>
    <name>Hulk</name>
    <rank>3</rank>
</e>

 

If I use the "Get Data" Wizard to build my xpath from the ResponseAsXml, and grab the ID for Hulk, I get this and it works:

 

     //*:e[3]/*:id[1]

 

However I am not always guaranteed that it will be the third "e" element, so when I attempt to grab it based on the name, such as:

 

    //*:e[name='Hulk]/*:id[1]

 

It fails and returns null far as I know this should be the correct syntax, I have also tried:

   

    //*:e[name[text()='Hulk]]/*:id[1]

    //*:e[/name[text()='Hulk]]/*:id[1]

    //*:e[/name='Hulk']/*:id[1]

 

etc. Any help would be appreciated.