KB Article #71639

XML - How to avoid empty tags in an XML file

Problem

--The goal is to avoid empty tags in an XML file.
So there are some XML elements in an XML file which do not have any information in the field. It is just the begin tag and the end tag of the XML field which appears. The purpose is not to send around empty files, just because it is an XML file.
What should be configured in business document in order to send only those XML tags with an XML document, which have a content besides the tag names.


Resolution

* 1. In case one knows that there won't be any input at all -> do not map the field at all! As result we do not get XML output for this field (no field value, no tag subsequently)
2. In case sometimes there will be some input, you must define a local variable in DML mapper and use the value of it while mapping. The code snippet looks like:
IF %variable <>"" then {
           $:=%variable}
Also a field not written will be called absent. "absent" is a DML keyword that can be used too.