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.

Categories:
  • Suggested answer
    Inge M. Bruvik Profile Picture
    32,718 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.

  • 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!

  • 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

  • Suggested answer
    Bilal Haider Profile Picture
    41 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 .

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,860 Test role Public

#2
Ludwig Reinhard Profile Picture

Ludwig Reinhard 229,831 Microsoft Employee

#3
Martin Dráb Profile Picture

Martin Dráb 225,155 Moderator

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans