When adding a new element I see the xmlns
attribute getting added with empty string. How can I avoid this? I have seen few answers but they are either in Java or .Net. Still tried those but they don't work. I need a solution for VBScript.
'load the xml file
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.load(strFilePath)
'get all <MainError> nodes in the xml
Set mainNode = objXMLDoc.documentElement.SelectNodes("//MainError")
'get child nodes for the first <MainError> node
Set childNodes = mainNode(0).ChildNodes
Set objErrorNode = objXMLDoc.createElement("ChildError")
objErrorNode.text = "somevalue"
mainNode(0).appendChild(objErrorNode)
Output:
<MainError><ChildError xmlns="">somevalue</ChildError></MainError>