XMLData Object

Description

An object representing an XML block.

IMPORTANT

All XMLData objects, methods, and properties are compatible with the namespace and XPath standards.

Therefore, when including a namespace in an XPath value, ensure that the namespace is defined at the same level in which the XPath is evaluated.

For more details on XML, namespace, and XPath standards, see the World Wide Web Consortium (W3C) website.

This object can be accessed using one of the following methods:

Methods and Properties

Method AddCDataSectionAn object representing an XML block.
Method AddCommentAdds a comment to the XMLData document..
AddNamespaceAdds the specified namespace to the namespace collection used by the XMLData object.
CDATASectionsReturns the document's CDATA sections as a collection
CheckExecutes a checkpoint on an XML object return value supplied by a Web service.
ChildElementsByPathReturns all of the child elements that reside in the specified path.
CloneReturns an exact copy of the XMLData object.
CommentsReturns the document comments in a collection.
CompareCompares the specified XML document with the current XMLData object and creates a new XMLData object containing the differences.
CreateDocumentCreates a new, empty XML document with a specified root name.
GetRootElementReturns an XMLElement object, representing the block's root element.
GetValidationErrorRetrieves the description of the specified error from the most recent schema validation.
GetValidationErrorsNumberReturns the total number of errors that occurred in the most recent schema validation.
GetVersion

Returns the XML version of the block.

LoadInitializes an XML object using the specified XML string.
LoadFileInitializes an XML object using the specified XML file.
OutputInserts the value of an XML object return value supplied by a Web service into an output value column.
RemoveCDATASectionRemoves the specified CDATA section from the XMLData document.
RemoveCommentRemoves the specified comment section from the XMLData document.
SaveFileSaves the XMLData document to the specified file.
SetRootElementSets the specified XMLElement object as the root element of the XMLData object and returns the newly set element root.
ToStringReturns a string representation of the XML object.
ValidateChecks whether the XMLData object conforms to the specified schema file.

Back to top

AddCDATASection Method

Description

Adds a CDATA section to the XMLData document.

Syntax

XMLData.AddCDATASection CDataSectionString

Argument

Type

Description

CDataSectionString

String

The CDATA section to add.

Back to top

AddComment Method

Description

Adds a comment to the XMLData document.

Syntax

XMLData.AddComment CommentString

Argument

Type

Description

CommentString

String

The comment to add.

Back to top

AddNamespace Method

Description

Adds the specified namespace to the namespace collection used by the XMLData object.

Syntax

XMLData.AddNamespace Prefix, URI

Argument

Type

Description

Prefix

String

The prefix to associate with the namespace you are adding.

URI

String

The namespace to add.

IMPORTANT

After using this method to add a namespace, you must add the namespace prefix to any XPATH expressions used in subsequent steps. If an XPATH expression does not include a prefix, the namespace URI (uniform resource identifier) will be an empty namespace (and not the default namespace).

Back to top

CDATASections Property

Description

Returns the document's CDATA sections as a collection.

Syntax

XMLData.CDATASections

Return Value

XMLItemColl Object

IMPORTANT

The returned item collection is a copy of the collection of the document's CDATA sections. Therefore, any changes you make to a document's CDATA section after retrieving the collection (such as adding or removing a CDATA section) will not be included. For example, if you use the Count property on the returned item collection, the returned value will be the same before and after adding or removing CDATA sections to or from the actual XML document. To ensure that the collection is up-to-date after changes are made, use the CDATASections property again to retrieve the updated collection.

Back to top

Check Method

Description

Executes a checkpoint on an XML object return value supplied by a Web service.

Note: This method is only available with the UFT One Web Services Add-in. You insert a checkpoint on an XML object return value using the Step Generator. For more details, see the Web Services section in the UFT One Help Center.

Syntax

XMLData(description).Check CheckPoint(Name)

Argument

Type

Description

CheckPoint (Name)

Variant

The checkpoint object, which contains the expected values to be compared and verified during the test run.

Note: If you want to retrieve the return value of a checkpoint, you must add parentheses around the name of the checkpoint in the statement. For example:

a = Browser("MyBrowser").Page("MyPage").Check (CheckPoint("MyProperty"))

Return Value

Boolean

Back to top

ChildElementsByPath Property

Description

Returns all of the child elements that reside in the specified path.

Syntax

XMLData.ChildElementsByPath(XMLPath)

Argument

Type

Description

XMLPath

String

The path containing the child element from which you want to retrieve the child element set. You can use the XPath or a UNIX-style file system path. For example: /elem1/elem2/../elem3

To return child elements of the current element node, use "."

Return Value

XMLElementsColl Object

IMPORTANT

The returned item collection is a copy of the collection of the selected child elements. Therefore, any changes you make to these elements after retrieving the collection (such as adding or removing an element) will not be included. For example, if you use the Count property on the returned item collection, the returned value will be the same before and after adding or removing elements to or from the actual XML document. To ensure that the collection is up-to-date after changes are made, use the ChildElementsByPath property again to retrieve the updated collection.

Back to top

Clone Method

Description

Returns an exact copy of the XMLData object.

Syntax

XMLData.Clone

Return Value

XMLData Object

Back to top

Comments Property

Description

Returns the document comments in a collection.

Syntax

XMLData.Comments

Return Value

XMLItemColl Object

IMPORTANT

The returned item collection is a copy of the collection of document comments. Therefore, any changes you make to a document comment after retrieving the collection (such as adding or removing a comment) will not be included. For example, if you use the Count property on the returned item collection, the returned value will be the same before and after adding or removing comments to or from the actual XML document. To ensure that the collection is up-to-date after changes are made, use the Comments property again to retrieve the updated collection.

Back to top

Compare Method

Description

Compares the specified XML document with the current XMLData object and creates a new XMLData object containing the differences. This method returns a boolean value indicating whether or not the two files are equal.

You can choose to compare all or some of the following DOM nodes: Document Type Declaration, Elements, Attributes, #text nodes, and CDATA sections. Comments are ignored.

For more details about the format of the resulting document, see Understanding the Resulting Document of an XMLData.Compare Statement.

Syntax

XMLData.Compare(XMLDocument, ResultXMLDocument, [Filter])

Argument

Type

Description

XMLDocument

XMLData

The XML document object that you want to compare to this XMLData object.

ResultXMLDocument

XMLData

An XMLData object containing the differences between the XMLData object and the XML document specified in the XMLDocument argument, according to the specified Filter argument (if any).

Filter

Number or pre-defined constant

Optional. The XML DOM node information to be compared:

0 or micXMLNone: Compares the elements and document type declaration of the specified XML documents.

1 or micXMLAttributes: Compares the attributes of the specified XML documents, in addition to their elements and document type declaration.

2 or micXMLCDataSections: Compares the CDATA sections of the specified XML documents, in addition to their elements and document type declaration.

4 or micXMLValues: Compares the #text nodes of the specified XML documents, in addition to their elements and document type declaration.

Note: If you do not use this parameter, the Document Type Declaration, Elements, Attributes, #text nodes, and CDATA sections are all compared.
You can specify more than one filter, separated by a plus (+) symbol. For example, micXMLValues+micXMLAttributes.

Return Value

Boolean

Back to top

CreateDocument Method

Description

Creates a new, empty XML document with a specified root name.

Syntax

XMLData.CreateDocument(RootName)

Argument

Type

Description

RootName

String

The root name for the new XMLData object.

Return Value

XMLData Object

Back to top

GetRootElement Method

Description

Returns an XMLElement object, representing the block's root element.

Syntax

XMLData.GetRootElement

Return Value

XMLElement Object

Back to top

GetValidationError Method

Description

Retrieves the description of the specified error from the most recent schema validation.

Syntax

XMLData.GetValidationError(ErrorNumberIndex)

Argument

Type

Description

ErrorNumberIndex

Number

The index number corresponding to the error you want to retrieve. Index values begin with 1.

Return Value

String. The string containing the error description.

IMPORTANT

This method is often used in conjunction with the GetValidationErrorsNumber Method, which enables you to retrieve the total number of errors in the list.

Back to top

GetValidationErrorsNumber Method

Description

Returns the total number of errors that occurred in the most recent schema validation.

Syntax

XMLData.GetValidationErrorsNumber

Return Value

Number. The total number of errors in the validation error list.

IMPORTANT

This method is often used in conjunction with the GetValidationError Method, which enables you to retrieve the error description of a specified error (index).

Back to top

GetVersion Method

Description

Returns the XML version of the block.

XMLData.GetVersion

Return Value

String

Back to top

Load Method

Description

Initializes an XML object using the specified XML string.

XMLData.Load (XMLString)

Argument

Type

Description

XMLString

String

The XML string containing the initialization information.

Back to top

LoadFile Method

Description

Initializes an XML object using the specified XML file. You can specify an XML file either from your file system or from ALM.

Syntax

XMLData.LoadFile (FilePath)

Argument

Type

Description

FilePath

String

The XML string containing the path or URL of the XML file to load.

If you enter a relative path, UFT One searches for the file in the current test's directory, and then in the folders listed in the Folders pane of the Options dialog box (Tools > Options > GUI Testing tab > Folders node). For more details, see the Micro Focus UFT One User Guide.

Back to top

Output Method

Description

Inserts the value of an XML object return value supplied by a Web service into an output value column.

Note: This method is only available with the UFT One Web Services Add-in. You insert an output value supplied by an XML object return value using the Step Generator.

Syntax

XMLData(description).Output CheckPoint(Name)

Argument

Type

Description

Checkpoint (Name)

Variant

The output object, which contains the name(s) of the column(s) to which to output the data.

Back to top

RemoveCDATASection Method

Description

Removes the specified CDATA section from the XMLData document.

Syntax

XMLData.RemoveCDATASection CDataSectionString

Argument

Type

Description

CDataSectionString

String

The CDATA string to remove.

Back to top

RemoveComment Method

Description

Removes the specified comment section from the XMLData document.

XMLData.RemoveComment CommentString

Argument

Type

Description

CommentString

String

The comment string to remove.

Back to top

SaveFile Method

Description

Saves the XMLData document to the specified file.

Syntax

XMLData.SaveFile FilePath

Argument

Type

Description

CommentString

String

The full path of the file to which you want to save the XMLData document.

Back to top

SetRootElement Method

Description

Sets the specified XMLElement object as the root element of the XMLData object and returns the newly set element root.

Note: This method copies the specified XMLElement and sets the copied object as the new XML root (replacing the previous root element).

Syntax

XMLData.SetRootElement XMLElement

Argument

Type

Description

XMLElement

XMLElement Object

The XMLElement that you want to set as the XMLData object's root element.

Return Value

XMLElement Object

Back to top

ToString Method

Description

Returns a string representation of the XML object.

Syntax

XMLData.ToString

Return Value

String

Back to top

Back to top

Validate Method

Description

Checks whether the XMLData object conforms to the specified schema file.

Syntax

XMLData.Validate ([SchemaLocation])

Argument

Type

Description

SchemaLocation

String

Optional. The URL or path (file system or ALM) of the schema upon which to validate the document.

If no value is specified and the XMLData object has an internal schema reference or declaration, the internal schema is used. Otherwise the method does not perform a validation, and it returns TRUE.

Return Value

Boolean. Returns TRUE if the XMLData object conforms to the schema (or if the validation was not performed) and FALSE if it does not.

IMPORTANT

If the method returns FALSE, you can retrieve the number and text of each validation error using the GetValidationError Method and the GetValidationErrorsNumber Method.

Back to top