I’m creating a new XML File out of a table. The problem is I don’t want the children of the root node to have the attribute xmlns. This happens automatically and its incorrect. If i have the attribute on the root element, no matter how it gets there it puts it in its child-nodes. How can I get rid of it?
A
Locals
Name DataType Subtype Length
L_DataXML Automation 'Microsoft XML, v6.0'.DOMDocument60
L_XMLElement Automation 'Microsoft XML, v6.0'.IXMLDOMElement
L_XMLAttribute Automation 'Microsoft XML, v6.0'.IXMLDOMAttribute
L_XMLNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
L_XMLOrderHeader Automation 'Microsoft XML, v6.0'.IXMLDOMNode
L_XMLOrderItemList Automation 'Microsoft XML, v6.0'.IXMLDOMNode
L_XMLOrderSummary Automation 'Microsoft XML, v6.0'.IXMLDOMNode
C/AL CODE
L_DataXML.loadXML('<ORDER xmlns="test"/>');
L_XMLNode := L_DataXML.documentElement;
L_XMLOrderHeader := L_DataXML.createNode(1,'ORDER_HEADER','');
L_XMLNode.appendChild(L_XMLOrderHeader);
XML
<?xml version="1.0"?>
<ORDER xmlns="test">
<ORDER_HEADER xmlns=""/>
</ORDER>
I had this problem too a while ago. Unforunatley, there is no way you can prevent that using XMLDOM. My workaround was to create the XML File with the error, load it into a bigtext variable and loop through it while erasing xmlns=””
Code:
Variables
Hope it helps