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 :
Small and medium business | Business Central, N...
Answered

Remove namespaces from child XML element in business central

(0) ShareShare
ReportReport
Posted on by 85

Hi everyone,

I am working on creating XML documents through XML datatype in business central, I have almost succeeded in doing so, I have created the required document but I am facing an issue in removing namespace from child element, for example


 

You can see the "xmlns" is repeated on every child element, if anyone has an idea how to remove the namespace from child please do share, I have tried few available functions but not worked for me.

var
    xmldoc: XmlDocument;
    xmlDec: XmlDeclaration;
    node: XmlElement;
    node1: XmlElement;
    
    
    begin
    xmldoc := XmlDocument.Create();
    xmlDec := xmlDeclaration.Create('1.0', 'ISO-81', 'no');
    xmlDoc.SetDeclaration(xmlDec);
    node := XmlElement.Create('Header', 'http://www.somethinh.com');
    node.Add(XmlAttribute.CreateNamespaceDeclaration('xsi', namespace1));
    
    //Header
    node1 := XmlElement.Create('Header');
    node.add(node1);
    //line
    node1 := XmlElement.Create('Header');
    node.add(node1);
    
    xmldoc.Add(node);
    end;

Here is the code for creating the document.

I have the same question (0)
  • Suggested answer
    Bilal Haider Profile Picture
    412 on at

    Hi Abdullah,

    I am not sure but try to use RemoveNamespace function available with NamespaceManager .

  • Abdullah Zafar Profile Picture
    85 on at

    Thank you Bilal Haider for your reply, I have tried NamespaceManager, but I haven't found a solution, maybe due to no prefix or URI value

  • Hasnain Ali Profile Picture
    134 on at

    Hi Abdullah,

    If the parent nodes namespace is the same as the child namespace, then child node's namespace wont be displayed!

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,105 Moderator on at

    You have to define the namespace in a text variable and add that to every node you add to the xml document.

    var

    Uri: Text;

    begin

    Uri := 'your namespance';

    node:= xmlelement.create('nodname',uri,nodevalue);

    end;

    Your node value being what you want the value of your node to be.

    I hope this helps.

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans