+ 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="http://www.testsite.com.org/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" TimeStamp="2001-12-17T09:30:47.0Z">


DOM.XmlNode testNode = bodyNode.addChildElement('MyTestNode', soapNamespace, '');
testNode.setNamespace('', 'http://www.testsite.com.org/2003/05');
testNode.setNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');


I can get <MyTestNode xmlns="http://www.testsite.com.org/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

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.