Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

XML import with XMLport - "following elements are not closed" after last row

Posted on by Microsoft Employee

I have created a XMLport (&codeunit) for importing purchase order header and po lines from an XML. All fields are defined as text and they are now evaluated into correct format & field - some are also being modified a bit more, eg. dates.

I followed the advices here and also many other feeds here and other forums.
https://docs.microsoft.com/en-us/dynamics-nav/walkthrough--inserting-data-from-xml-documents-to-multiple-tables

Currently I am experiencing an error when running the codeunit to import the data. The error is: "Unexptected end of file has occured. The following elements are not closed. Line 22, position 7."

The XML file I am trying to read has the last character ">" on line 22, position 6.

The codeunit has these lines:

varXmlFile.OPEN('filelocation.xml');
varXmlFile.CREATEINSTREAM(varInputStream);
XMLPORT.IMPORT(XMLPORT::"Custom Purch Order Import", varInputStream);
varXmlFile.CLOSE;

Should the codeunit somehow be modified that the end of the XML file is somehow checked and input ends there. Etc, etc?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: XML import with XMLport - "following elements are not closed" after last row

    And I must answer myself right away. The final row of the XML was missing, so error information given by NAV was very correct once again!.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans