Search code examples
xmlinfopath

InfoPath 2013 - do not create empty XML tag if field empty


I am trying to design an InfoPath 2013 form which would generate XML files to be later used outside my organization. I created my form basing on XSD schema later used to validate the XML document.

I'm having issues with optional fields. I have marked them as optional in the form itself (ie described them as optional to the users). However, if the fields are left blank, the resulting XML still contains the tags without values in between them. For example:

<etd:ImiePierwsze></etd:ImiePierwsze>

The problem is that according to the underlying schema, the above tag (and many others) cannot be empty. In another words, I have to either fill it with value of predetermined type, or not invlude the tag at all.

My question is: where in InfoPath could I set the field's property so that it does not appear in the resulting XML at all if it is not used?

Thanks a lot in advance.


Solution

  • OK I feel a little stupid, but I solved my own problem.

    The key feature of InfoPath was "Optional Sections" which pretty much solved my problem in entirety. I have marked the optional parts of my form as Optional Sections, which

    1. increased clarity of my form
    2. solved the problem of inserting redundant XML tags to my document.

    I'm leaving it here so that other errant novice InfoPath devs can make use of my discovery.