Where’s my node? Logic Apps Flat File Decode beware suppress empty nodes unintended effect


The flat file schema property 'suppress_empty_nodes' is described as "Indicates whether or not to remove empty XML nodes after the parser generates XML instance data." in the documentation https://msdn.microsoft.com/en-us/library/aa559329.aspx

Sandro Pereira blogs about how this can be helpful in his post Teach me something new about Flat Files.

However you will not want to suppress W3C-empty nodes like (i.e. has no value, even if it has attributes):

  <Header BatchDate="2018-11-28" RecordCount="123" PostAmt="123456.1200|123"></Header>

When the node is required in the schema as in:

       <xs:element minOccurs="1" maxOccurs="1" name="Header">

If you run and XML validation on the output which empty node was suppressed you will get an error like this:

       System.Xml.XmlException: The element 'MyRootNode' has invalid child element 'Loop'. List of possible elements expected: 'Header'.

So in the schemaInfo beware

       suppress_empty_nodes="true"

and as appropriate change it to

       suppress_empty_nodes="false"
Comments (1)
  1. David Burg says:

    This blog has been moved off the MSDN platform. Find further content and update at https://www.linkedin.com/today/author/daviburg

    Comments are locked as part of the blog migration, so please reach out to your customer support contact for assistance with Microsoft products and services.

Comments are closed.

Skip to main content