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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

XMLPORT not creating

(8) ShareShare
ReportReport
Posted on by 49
 
 
Hi ,
I've an XMLPORT whose declaration is :
 
XmlPort 50008 "MileStone XML"
{
    Direction = Export;
    Encoding = UTF8;
    FormatEvaluate = Xml;
    Format = Xml;
    UseDefaultNamespace = true;
   
    schema
    {
        tableelement(RigheBooking; "righe booking export")
 
XML is created correctly, but is missing the 
 
<?xml version="1.0" encoding="UTF-8"?>
 
any suggestion ?
Is there a way to add automatically ?
 
Fabrizio 
I have the same question (0)
  • Martin Dráb Profile Picture
    239,634 Most Valuable Professional on at
    Moved from Integration, Dataverse, and general topics forum to Small and medium business | Business Central, NAV, RMS forum, because it seems to be about Business Central. Please let me know if you disagree.
     
    Note that the header <?xml version="1.0" encoding="UTF-8"?> is optional (in XML 1.0).
  • Suggested answer
    Pallavi Phade Profile Picture
    5,622 Super User 2026 Season 1 on at
    Greetings , 
     

    By default, XMLports use the UTF-8 encoding standard, which is why the XMLport was created successfully. If you require a different encoding, it must be specified in the AL file.

    To include the XML declaration header automatically, you can enforce it in your AL file by setting the property below:

    Sample Example Below 
    xmlport 50100 MyXmlport
    {
        xmldeclaration = true; // Add this line
        schema
        {
            // ...existing code...
        }
        // ...existing code...
    }
     
  • GrisuX Profile Picture
    49 on at
    Hi,
    Xmldeclaration is not recognized, even if i'm in 
    IT Business Central 22.1 (piattaforma 22.0.56191.0 + applicazione 22.1.55890.56216)
    onprem (but workins as we are in cloud)
     
    i seems that xmldeclaration should be available since :
     
    The XMLDeclaration property for XMLports was introduced in Microsoft Dynamics 365 Business Central 2020 Release Wave 2 (version 17.0).
     
     
    something wrong with visual studio ?
    or XMLdeclaration has been implemented in a newer wave release than 22 ?
     
    Fabrizio
     
  • Suggested answer
    Pallavi Phade Profile Picture
    5,622 Super User 2026 Season 1 on at
    Dear Fabrizio
     
    You are correct — this is not supported. Since I wasn’t certain about the exact version earlier, let me clarify: the XML declaration needs to be appended before exporting. This can be done in a codeunit using the File data type in on-premises installations, or by using a Blob (Temp Blob) approach in the cloud.
     
    If you need code then i can guide you further .
     
    Regards 
    Pallavi Phade
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,424 Super User 2026 Season 1 on at
    Hi, I checked your code and noticed the following:
    Where are you opening the downloaded file?
    If you open the file in Edge or any other browser, you will not see the line <?xml version="1.0" encoding="UTF-8"?>.
     
     
    If you open the file in Notepad, you will be able to see the <?xml version="1.0" encoding="UTF-8"?>.
     
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,424 Super User 2026 Season 1 on at
    Why Diff: When you open the XML in a browser like Edge, the line <?xml version="1.0" encoding="UTF-8"?> is hidden because browsers parse XML as a structured document and only render the element tree, not the processing instructions; however, when you open the same file in a text editor like Notepad, you see the declaration because editors display the raw file content exactly as it is stored.
  • Suggested answer
    Chavda Dharmendra Profile Picture
    1,004 Super User 2026 Season 1 on at
    Yes @Khushbu Rajvi., you are right.
     
    I checked and showing same result as you mention.
     
     
  • Suggested answer
    YUN ZHU Profile Picture
    100,998 Super User 2026 Season 1 on at
    Hi, hope the following helps.
    Dynamics 365 Business Central: How to Export and Import Data (Using XMLports)
     
    Thanks.
    ZHU
  • Gerardo Rentería García Profile Picture
    26,790 Most Valuable Professional on at

    Hi, good day
    I hope this can help you, and give you some hints.

    Business Central XmlPort: Why the XML Declaration Looks Missing

    Best Regards
    Gerardo

  • Verified answer
    GrisuX Profile Picture
    49 on at
    Hi,
    sorry .. my fault.
    My and my colleague were working on the same git repo, and duw to a wrong fetch, he overrided  my changes.
    The problem was solved adding the 
    Format = Xml;
    at beninning this was not present in the xmlport, but it was when i took the screenshot of the code.
     
    that at beggining was not present.
     
    Many thanks for all the replies
     
    B. regards
    Fabrizi o

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,002 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,255 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,217

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans