SaveDocument

Description

Saves the serialized XML string of the DOM tree contained within the PBDOM_DOCUMENT object into a disk file.

Syntax

pbdom_document_name.SaveDocument(string strFileName)

Argument

Description

pbdom_document_name

The name of a PBDOM_DOCUMENT object

strFileName

The name of the disk file to which the contents of the current PBDOM_DOCUMENT object is to be serialized


Return value

Boolean.

Returns true if a new document was successfully saved to a disk file, and false otherwise.

Throws

EXCEPTION_INVALID_ARGUMENT -- The input string specifying the file name is invalid. This can happen if the string has been set to null using the PowerScript SetNull method.

EXCEPTION_MEMORY_ALLOCATION_FAILURE -- Insufficient memory was encountered while executing this method.

Usage

A PBDOM_DOCUMENT object that has been created from an existing XML document or string can differ from its original after it has been converted back to an XML string or document. This can occur even if no modifications have been made to the PBDOM_DOCUMENT object using PowerScript.

This can occur if the original XML document or string referred to an external DTD that mandates the inclusion of default attributes. In this case, PBDOM complies with the rules of the DTD and inserts these required attributes into the relevant elements while building up the in-memory DOM tree.

When the PBDOM_DOCUMENT object is saved and converted back to an XML document, these default attributes are saved in the document.

The SaveDocument method saves files in the specified encoding. When creating a new document, the default value of encoding is UTF-16LE. When opening an existing document, the encoding is specified in the declaration of the document.

If there is no declaration in the document or no specified encoding in the declaration, the encoding is UTF-16LE by default.

If standalone is an empty string, it will be set to "no" by default when saving the string into a disk file. If version is invalid, no declaration will be added. If encoding is invalid, no exception will be thrown, but an empty document will be generated.

See also

NewDocument

SetXMLDeclaration

GetXMLDeclaration