Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Extra namespace coming...
Finance forum
Suggested answer

Extra namespace coming in document node

Posted on by 207
 Hi All,
 
I am trying to generate xml file.
But there is extra namespace coming in CstmrCdtTrfInitn  node.
 
 
 
Expected :
 
 
Please see my code below
 rootNode = xmlDoc.documentElement();


 docNode = xmlDoc.createElement2('Document',"urn:iso:std:iso:20022:tech:xsd:pain.001.001.03");
 docNode.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
 xmlDoc.appendChild(docNode);

 XmlNode CstmrNode;

 CstmrNode = xmlDoc.createElement('CstmrCdtTrfInitn');
 docNode.appendChild(CstmrNode);                        //todo
 xmlElement = xmlDoc.createElement('GrpHdr');
 NodeName =  CstmrNode.appendChild(xmlElement);
Please help.
 
Thanks,
Priya
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 228,706 Most Valuable Professional on at
    Extra namespace coming in document node
    The reason is that you didn't specify the namespace of CstmrCdtTrfInitn, therefore the namespace of CstmrCdtTrfInitn is different than the namespace of its parent node (empty vs. http://www.w3.org/2001/XMLSchema-instance).
     
    You seem to want the same namespace for all nodes, therefore you should do that. You can, for example, use createElement2() instead of createElement(), because createElement2() has a parameter for the namespace URI.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,572 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,706 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans