I am converting from one XML format into another XML format, where my XML structure is as follows.
Hello
199
CAI - CASH AGAINST
I want to suppress the empty values. My output structure should be
Hello
199
CAI - CASH AGAINST
I am using loop over RefTypeCd which has (19,WS,V0,TT,4B,BLT). I have tried by changing genearteRequiredTags value to false in documentToXMLString, but it does not help me. Does anyone has a solution. Any help would be appreciated. Thanks.
generateRequiredTag is the right option that would help you to remove empty tags. This requires documentTypeName to be passed. If it still doesn’t happen, the way you are passing input to this service might not be right. Check for the root node whether it is mapped to document or under document
Mr.Senthil it should work both ways and giving required tags to false and document type name some times works unexpected due to the underlying schema/DTD elements forces to be present for null/empty values.
I would say he can try both options with and with out setting docTypeName:
What exactly you tried can you elaborate the trying please?
How ever I know there are some rude ways to remove from the xmldata but its all depends on the requirement always required vs not required in the output data.
Hi RMG/Senthil, I am attaching the generated sample XML file can you please provide me the sample code to remove empty XML tags from it as in your previous posts you have mentioned that documentTypeName is not mandatory. Thanks. Sample.xml (6.65 KB)
I found an alternate solution by mapping them conditionally I think that is not the right approach, tomorrow if we want the null tags to be generated it will become a problem. So I want to see how can we make use of the property generateRequiredTags. Thanks.
Could you please provide me the sample code to suppress the empty tags by making use of the property generateRequiredTags. At least for the following sample code in the above XML document.