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

  • BlackPanther Profile Picture
    BlackPanther 10 on at
    RE: Min Occurs Element Property in XMLport

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

  • Verified answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Min Occurs Element Property in XMLport

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans