web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Min Occurs Element Property in XMLport

(0) ShareShare
ReportReport
Posted on by 10

I would like my XMLport to only show elements if a value is required. There is an element property called Min Occurs, and its value can be set to Zero. Unfortunately when I have set the property value to zero for an element, on running the XMLport, the exported XML records still show the element, even when there is no value. Have I misunderstood the purpose of this element property?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    The MinOccurrs and MaxOccurs properties of an element control how NAV parses an XML document. If it's MinOccurs = 0 and MaxOccurs =1 then a valid XML document can contain the element 0 or 1 times only in the correct structure of the document.

    Unfortunately when exporting an XML, NAV doesn't handle "nulls" and MinOccours is not validated. MinOccours works only for import.

    My advice is to add post processing process that removes the nodes from xml file, something like:

    xmlDoc := xmlDoc.XmlDocument;

    xmlDoc.Load(FileName);

    XMLNodeList := xmlDoc.SelectNodes('//YourEmptyNode[. = ""]');

    FOR i := 0 TO XMLNodeList.Count - 1 DO BEGIN

      XMLNode := XMLNodeList.Item(i);

      XMLNode.ParentNode().RemoveChild(XMLNode);

    END;

    xmlDoc.Save(FileName);

    where YourEmptyNodeis the name of your empty note.

  • BlackPanther Profile Picture
    10 on at

    Thank you for answering my question. I will give your suggested work around a go.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans