Forum Discussion

KMD_A_S_User_2's avatar
KMD_A_S_User_2
New Contributor
15 years ago

How to remove tags with null values in MakrupBuilder

I am trying to build a xml document in a mock response. And i'm using MarkupBuilder in order to do so.

But the requirement to the xml document is that tags with null values should be removed.
For example:

<a><b>1</b><c>2</c><d></d></a>

should finally output like this:

<a><b>1</b><c>2</c></a>

I notice there are 2 methods:
isOmitNullAttributes()
isOmitEmptyAttributes()
in MarkupBuilder, but they are only for attributes.

Is there any quick way I can achieve this?
Thanks in advance.

2 Replies

  • Hi!

    sorry, we are not very familiar with the workings of MarkupBuilder, maybe you can get help on the related Groovy Forum Boards?

    regards!

    /Ole
    eviware.com
  • William_Willafo's avatar
    William_Willafo
    Occasional Contributor
    Have you tried leaving the emtpy tag there and running your mock server?

    I know that for regular SOAP TestRequests, that if you have empty elements like <d></d> then soapUI Pro will remove the tag altogether from the request when it is sent.

    Very well could be different for mocks though.