Document Property

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use this property to obtain access to the contents of an XML document stored by the XMLCheckpoint project element that corresponds to XMLCheckpoint. The property returns an object implementing the IXMLDOMDocument interface. This interface is part of Microsoft XML DOM. You can use methods and properties of this interface to work with nodes in the stored document.

Declaration

XMLCheckpointObj.Document

Read-Only Property An IXMLDOMDocument object
XMLCheckpointObj An expression, variable or parameter that specifies a reference to an XMLCheckpoint object

Applies To

The property is applied to the following object:

Property Value

An object implementing the IXMLDOMDocument interface.

Remarks

For information on methods and properties of the IXMLDOMDocument interface and about DOM, see the XML Core Services and Document Object Model article in the MSDN Library.

The XMLCheckpoint object provides access to a copy of the element’s data. Changes made to the stored data via the Document property will not be stored to the element and will not be displayed in the XMLCheckpoint Element editor.

Example

The following example demonstrates how you can use the Document property to load data from an external XML document to the stored XML checkpoint.

JavaScript, JScript

function XMLDocumentDemo()
{

  var XMLDoc, XMLFile;
  XMLDoc = XML.MyXMLCheckpoint.Document;
  XMLFile = "D:\\Work Folder\\SampleXMLFile.xml";

  // Checks if the external XML file exists.
  if (aqFile.Exists(XMLFile))
    {
    // Loads data from SampleXMlFile.xml to MyXMLCheckpoint.
    XMLDoc.load(XMLFile);

    // Posts the data loaded to MyXMLCheckpoint to the log.
    Log.Message("XML Checkpoint content", XMLDoc.xml);
    }
  else
    // Posts an error message to the log.
    Log.Error("The external XML file does not exist.");


}

Python

def XMLDocumentDemo():
  XMLDoc = XML.MyXMLCheckpoint.Document;
  XMLFile = "D:\\Work Folder\\SampleXMLFile.xml"
  # Checks if the external XML file exists.
  if aqFile.Exists(XMLFile):
    # Loads data from SampleXMlFile.xml to MyXMLCheckpoint.
    XMLDoc.load(XMLFile)
    # Posts the data loaded to MyXMLCheckpoint to the log.
    Log.Message("XML Checkpoint content", XMLDoc.xml)
  else:
    # Posts an error message to the log.
    Log.Error("The external XML file does not exist")

VBScript

Sub XMLDocumentDemo
  Dim XMLDoc, XMLFile

  Set XMLDoc = XML.MyXMLCheckpoint.Document
  XMLFile = "D:\Work Folder\SampleXMLFile.xml"

  ' Checks if the external XML file exists.
  If aqFile.Exists(XMLFile) Then
    ' Loads data from SampleXMlFile.xml to MyXMLCheckpoint.
    Call XMLDoc.load(XMLFile)

    ' Posts the data loaded to MyXMLCheckpoint to the log.
    Call Log.Message("XML Checkpoint content", XMLDoc.xml)
  Else
    ' Posts an error message to the log.
    Log.Error("The external XML file does not exist.")
  End If

End Sub

DelphiScript

procedure XMLDocumentDemo();
var XMLDoc, XMLFile;
begin

  XMLDoc := XML.MyXMLCheckpoint.Document;
  XMLFile := 'D:\Work Folder\SampleXMLFile.xml';

  // Checks if the external XML file exists.
  if aqFile.Exists(XMLFile) then
    begin
    // Loads data from SampleXMlFile.xml to MyXMLCheckpoint.
    XMLDoc.load(XMLFile);

    // Posts data loaded to MyXMLCheckpoint to the log.
    Log.Message('XML Checkpoint content', XMLDoc.xml)
    end
  else
    // Posts an error message to the log.
    Log.Error('The external XML file does not exist.');


end;

C++Script, C#Script

function XMLDocumentDemo()
{

  var XMLDoc, XMLFile;
  XMLDoc = XML["MyXMLCheckpoint"]["Document"];
  XMLFile = "D:\\Work Folder\\SampleXMLFile.xml";

  // Checks if the external XML file exists.
  if (aqFile["Exists"](XMLFile))
    {
    // Loads data from SampleXMlFile.xml to MyXMLCheckpoint.
    XMLDoc["load"](XMLFile);

    // Posts the data loaded to MyXMLCheckpoint to the log.
    Log["Message"]("XML Checkpoint content", XMLDoc.xml);
    }
  else
    // Posts an error message to the log.
    Log["Error"]("The external XML file does not exist.");


}

See Also

About XML Collection
Creating XML Checkpoints
About XML Checkpoints

Highlight search results