cancel
Showing results for 
Search instead for 
Did you mean: 

Empty Elements in XML with Data from Excel

DavidSEM_Admin
Occasional Contributor

Empty Elements in XML with Data from Excel

Hello community

I would like to fill my rigid XML schema with data from an Excel file. Now there are test cases, where I don't need any data from the excel (Data Driven Testing | SoapUI). How can I send the schema correctly although the field is "empty"?

 

Do I need to set some settings right? 

 

For instance:

 

<v13:FamilyName>
<v13:PrimaryValue>XXAD</v13:PrimaryValue>
<!--0 to 5 repetitions:-->
<v13:AlternativeSpelling>
<v13:Value></v13:Value>
<v13:Source>
<v13:Code></v13:Code>

Tags (1)
17 REPLIES 17
richie
Community Hero

Re: Empty Elements in XML with Data from Excel

Hey @DavidSEM_Admin,

I dont know what you mean as "fill your rigid XML schema with data"....the schema is the bit that validates your request....its not the XML document/instance (your payload), right?

Anyway, re: your question. Can you confirm.....are you sourcing a whole xml payload from your excel or are you only sourcing specific tag values in your xml file?

Its pretty easy if you whole xml payload is in the file, just domt source it.
Bit more fiddly if youre talking about specific tag values as we need to identify what you mean by "empty".

Empty elements can appear as
<elementName />
or
<elementName></elementName>

Can you please clarify exactly what you need?

Cheers,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
DavidSEM_Admin
Occasional Contributor

Re: Empty Elements in XML with Data from Excel

Hi @richie 

 

Thank you very much for your reply and for your help. I will try to explain myself more clearly.

 

  • My goal is to source specific tag values in my xml-file from a excel-sheet. For instance with this example request (without header, see below). As you can see i already tagged and generated the values from a DataBase (Excel). Now some of the values will be empty in the Excel Sheet. Now ReadyAPI correctly shows the empty elements like you described:
  •  
  • <v13:FirstName>
    <v13:PrimaryValue>${TestData_DataEntry#FirstName}</v13:PrimaryValue>
    </v13:FirstName>
  • =
  • <v13:FirstName/>  <----- = empty

Now i need from SoapUIpro to delete these "nested tags" when a request is sended. I have selected "Remove Empty Content " as "true". But it only deletes partially of the tags. It only deletes the "PrimaryValue" and leaves FirstName. I need SoapUI to delete the whole tag and not only "PrimaryValue" 


Thank you very much for your help. If you need further specification pls let me know

ChrisAdams
Community Leader

Re: Empty Elements in XML with Data from Excel

Hi,

 

If I understand it, you want SoapUI to automatically remove empty/redundant tags, but SoapUI isn't doing this as you need need.

 

This may confuse matters, and not fix the issue, but as a workaround, use data driven to 'inject' the whole tag into the request instead of just the values.  That way, you have more control over what is inserted into the request, esp empty tags.

 

Chris

DavidSEM_Admin
Occasional Contributor

Re: Empty Elements in XML with Data from Excel

@ChrisAdams 

 

Is there really no other way to automatically deleted the parent element?

ChrisAdams
Community Leader

Re: Empty Elements in XML with Data from Excel

Hi,

"Is there no other way to delete parent elements?".  Sorry, I really don't know.

 

I've used SoapUI's data driven test functionality extensively.  In the main, my test data wholly aligns to the payload, so I usually don't have to worry about empty nodes and having to remove them.

 

On the flip side, I have built validation tests where I'm checking for the existence (and non-existence) of nodes as well as testing expected response where some node is empty.

 

For this, I still use data-driven tests, but instead of squirting in individual values, I've squirted in the whole request.  I've also used data driven tests where my Excel data is a path to a file and I've 'pulled in' the file contents using a Groovy script step.  The files contain the whole request I want to send.

 

To sum up, whilst SoapUI may not always offer what you need, I've never not been able to use the functionality to work around such limitations.

 

 

ZDGN
Contributor

Re: Empty Elements in XML with Data from Excel

Hi @DavidSEM_Admin,

 

@ChrisAdams is pointing something that I find really interesting.

As far as I understand, you could use some groovy code to dynamically generate your xml content depending on the values extracted form your excel file.

 

That is to say that you keep your data driven test step, and then use groovy code to add or not xml element to the request.

This should make the deal for you.

 

David.

DavidSEM_Admin
Occasional Contributor

Re: Empty Elements in XML with Data from Excel

@ChrisAdams can you show or give an example how you did this?

 

"For this, I still use data-driven tests, but instead of squirting in individual values, I've squirted in the whole request.  I've also used data driven tests where my Excel data is a path to a file and I've 'pulled in' the file contents using a Groovy script step.  The files contain the whole request I want to send."

 

i am not sure that I get this possible solution right...

DavidSEM_Admin
Occasional Contributor

Re: Empty Elements in XML with Data from Excel

HI@ZDGN 

 

i also found that a groovy script would possible help. However, I have no idea how to write such a groovy code to make it work. 

 

Could you tell me how or do you have such a working groovy code?

ChrisAdams
Community Leader

Re: Empty Elements in XML with Data from Excel

Hi,

Yes, this exactly.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors