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
SalesRedSalesRed 

Adding an element to an XMLNode without a namespace prefix?

 

Hi,

 

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) 
sfdcfoxsfdcfox
Just add a regular attribute. Namespaces define the elements within the element. Take a look at Dom.XMLNode.setAttribute.