Modifying Elements of the XML Collection

Applies to TestComplete 14.30, last modified on November 21, 2019

The Stores | XML collection contains XMLCheckpoint elements. XMLCheckpoint elements are used to compare and verify XML documents. They store XML data and comparison settings. You can modify the elements’ data using the editor or by writing script code or keyword test.

Note: If you need to automatically update all data stored in the XMLCheckpoint element, see Updating Elements of the XML Collection.

Modifying Data in the Editor

You can view and modify an element’s data using the XMLCheckpoint Element editor.

The Tree View page of the editor displays stored data in a tree form. You can modify tree nodes using in-place editors and toolbar items. On the Source page of the editor you can modify the XML source code.

The XMLCheckpoint editor also lets you change comparison settings. For complete information on working with the editor, see About XMLCheckpoint Element Editor.

Modifying Data From Tests

To get scripting access to elements of the XML collection, use the XML object. This object contains properties whose names coincide with the names of the collection’s elements and that return XMLCheckpoint objects. Use properties of the object to access and modify stored XML data and comparison settings.

The XMLCheckpoint object provides scripting access to a copy of stored data. In other words, changes you make in tests will not be applied to values and comparison settings that are stored in the project and displayed in the editors. All changes will be lost after the test execution is over.

The Document property of the XMLCheckpoint object returns an object implementing the IXMLDOMDocument interface (defined in Microsoft XML DOM). This object provides a scripting interface to the stored XML data and lets you read and modify values of stored nodes and attributes, change the nodes’ order, add new nodes and perform other tasks.

For instance, the following code demonstrates how you can load data from a file to a stored XMLCheckpoint element called XmlCheckpoint1:

JavaScript, JScript

XML.XmlCheckpoint1.Document.load("c:\\MyFile.xml");
Log.Message("Loaded data", XML.XmlCheckpoint1.Document.xml);

Python

XML.XmlCheckpoint1.Document.load("c:\\MyFile.xml")
Log.Message("Loaded data", XML.XmlCheckpoint1.Document.xml)

VBScript

Call XML.XmlCheckpoint1.Document.load("c:\MyFile.xml")
Call Log.Message("Loaded data", XML.XmlCheckpoint1.Document.xml)

DelphiScript

XML.XmlCheckpoint1.Document.load('c:\MyFile.xml');
Log.Message('Loaded data', XML.XmlCheckpoint1.Document.xml);

C++Script, C#Script

XML["XmlCheckpoint1"]["Document"]["load"]("c:\\MyFile.xml");
Log["Message"]("Loaded data", XML["XmlCheckpoint1"]["Document"]["xml"]);

For complete information on IXMLDOMDocument, its methods and properties and for information on other Microsoft XML DOM objects, see the XML Core Services and Document Object Model article in the MSDN Library.

To obtain scripting access to the comparison settings of an XMLCheckpoint element, use the Options property of the XMLCheckpoint object. This property returns the XMLCheckpointOptions object, which has properties that provide access to the appropriate comparison settings:

You can use the XML and XMLCheckpoint objects and their methods and properties in keyword tests by using the Call Object Method or Run Code Snippet operation.

See Also

About XML Collection
About XML Checkpoints

Highlight search results