web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    264 on at
    RE: Remove namespaces from child XML element in business central

    Hi Abdullah,

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

  • Abdullah Zafar Profile Picture
    85 on at
    RE: Remove namespaces from child XML element in business central

    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
    132 on at
    RE: Remove namespaces from child XML element in business central

    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,033 Moderator on at
    RE: Remove namespaces from child XML element in business central

    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

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans