function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Adding an element to an XMLNode without a namespace prefix?




I was wondering,  If want to add the following to an XML Node using Dom.XMLNode function how can I do so


<MyTestNode xmlns="" xmlns:xsi="" TimeStamp="2001-12-17T09:30:47.0Z">


DOM.XmlNode testNode = bodyNode.addChildElement('MyTestNode', soapNamespace, '');
testNode.setNamespace('', '');
testNode.setNamespace('xsi', '');


I can get <MyTestNode xmlns="" xmlns:xsi="">

If I want to ad TimeStamp="" within this without it having a namespace prefix "xmlns" how can I do this?


Thanks in advacnce for any help.

Best Answer chosen by Admin (Salesforce Developers) 
Just add a regular attribute. Namespaces define the elements within the element. Take a look at Dom.XMLNode.setAttribute.