Ask a Question

how to modify a xml file using Test complete

Baker_3-4
New Contributor

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)
}


}

2 REPLIES 2
sonya_m
SmartBear Alumni (Retired)

Thanks for your question!

 

Hi @ApplePen @anupamchampati @tphillips , any ideas on how to fix this?


Sonya Mihaljova
Community and Education Specialist

anupamchampati
Frequent Contributor

Hello ,

Can you please share the error log what error you are getting?

Also ExecuteXml seems to be separate function, can you please share that as well.

 

Thanks

cancel
Showing results for 
Search instead for 
Did you mean: