KMD_A_S_User_2
15 years agoNew Contributor
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.
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.