Forum Discussion

ccoles's avatar
ccoles
New Contributor
5 years ago

Property Transfer to Excel

Hi All,

I am pretty new to Ready API.  I have a SoapUI pro project that has a request XML and I want to take some data from the response message and pass it into an Excel file.  Image below shows set up.

In my property transfer step I want to the @uuid which is fine I can get that to work and output to excel.  I also was to take some data from the section that says a:Respon... (last bit on Response section on the screen shot above).

 

This is some of what in in there.  If for example I wanted to get the postcode, I'm not sure how  I would go about it? 

<?xml version="1.0" ?><PolMessage xmlns="" Type="TransactionResponse" Version="1"><TranResult TranName="QuoteDetail" Completed="Y" ErrorCount="0" /><SchemeResult Ref="LVAO" Completed="Y" ErrorCount="0"><PolData Type="Output"><ProposerPolicyholder><ProposerPolicyholder_Type Val="P" Desc="Private" /><ProposerPolicyholder_NoOfVehiclesAvailableToFamily Val="0" /><ProposerPolicyholder_DateOfBirth Val="18/08/1944" /><ProposerPolicyholder_AddressLine1 Val="5, St Peters Hill" /><ProposerPolicyholder_AddressLine2 Val="Test Town" /><ProposerPolicyholder_PostCodeSector Val="BB7 1" Desc="BB7 1" /><ProposerPolicyholder_PostCodeFull Val="BB7 1QS" />

 

This is what my data sink looks like

Would really appreciate any help or advice as I am a complete novice.

 

Thanks

Charlene

 

  • Hey ccoles 

     

    The problem is the unescaped XML characters you have in your payload - I can't see your full payload in the screenshot, I can only see a segment - but I think the contents of the a:Response tag are unescaped XML.

     

    unescaped XML represents the < > characters as &lt; and &gt; character strings.

     

    The trouble with your payload containing these characters is that the XML parser that separates out the payload's tags ignores everything and treats it as character data - NOT XML.

     

    If all the XML in your payload used < > instead of &lt; and &gt;, you wouldn't have this problem

     

    There's a couple of approaches I've used to deal with this before now.  You can either use groovy script, but if youre a ReadyAPI! newbie I wouldn't suggest or you can use the native functionality.

     

    What you need to do is pass the whole unescaped string into a property and then pick out the attributes you need into additional properties.  This will allow you to grab what you need from the unescaped string.  This is the same approach as if you have a CDATA wrapper in your XML payload - the CDATA tag wrapper tells the XML parser to ignore the content and treat the string as character data, not XML (CDATA is typically used when you have any of the 5 XML entities as values in your XML elements --> &lt; , &gt;, &quot;, &apos; and &amp; which represents the specific characters <,  >, ", ', and &.

     

    So - as stated above, you need to pass the unescaped string to a property and then pick out the values from the string property into another property.

     

    I've done this several times - follow the instructions via this page and this will sort!

     

    ta

     

    rich

     

     

     

  • richie's avatar
    richie
    Community Hero

    Hey ccoles 

     

    The problem is the unescaped XML characters you have in your payload - I can't see your full payload in the screenshot, I can only see a segment - but I think the contents of the a:Response tag are unescaped XML.

     

    unescaped XML represents the < > characters as &lt; and &gt; character strings.

     

    The trouble with your payload containing these characters is that the XML parser that separates out the payload's tags ignores everything and treats it as character data - NOT XML.

     

    If all the XML in your payload used < > instead of &lt; and &gt;, you wouldn't have this problem

     

    There's a couple of approaches I've used to deal with this before now.  You can either use groovy script, but if youre a ReadyAPI! newbie I wouldn't suggest or you can use the native functionality.

     

    What you need to do is pass the whole unescaped string into a property and then pick out the attributes you need into additional properties.  This will allow you to grab what you need from the unescaped string.  This is the same approach as if you have a CDATA wrapper in your XML payload - the CDATA tag wrapper tells the XML parser to ignore the content and treat the string as character data, not XML (CDATA is typically used when you have any of the 5 XML entities as values in your XML elements --> &lt; , &gt;, &quot;, &apos; and &amp; which represents the specific characters <,  >, ", ', and &.

     

    So - as stated above, you need to pass the unescaped string to a property and then pick out the values from the string property into another property.

     

    I've done this several times - follow the instructions via this page and this will sort!

     

    ta

     

    rich