Forum Discussion

Baker_3-4's avatar
Baker_3-4
New Contributor
3 years ago

how to modify a xml file using Test complete

I am using the below method to modify the xml but it seems not working . please any idea how to do it 

 

function ModifyXml(fileName, childNode,nodeNum,modifyNodeNum,text)
{

// If you have MSXML 6:
Doc = Sys.OleObject("Msxml2.DOMDocument.6.0");

Doc.async = false;

// Load data from a file
Doc.load(fileName)

Nodes = ExecuteXml(Doc,fileName, childNode);
// Process the node
for(i = 0; i < Nodes.length; i++)
{
// Get the node from the collection of the found nodes
Node = Nodes.item(i);
if ( i==nodeNum)
{
// Get child nodes
ChildNodes = Node.childNodes;

ChildNodes.item(modifyNodeNum).text = text
Log.Message(ChildNodes.item(modifyNodeNum).text + ": " + ChildNodes.item(2).text);

break;
}

Doc.save(fileName)
}


}