XML.Document

Inherits from XML.Node

Description

A class that represents an XML Document.

Properties

loadError The integer value of the error encountered while loading a document.
loadErrorName The string name of the error encountered while loading a document.
root Return the root element of the document.

Methods

saveAs Saves the XML file to disk. Returns XML_NO_ERROR on success, or an errorID (see loadError above).

Details

Do no remove, this fixes the anchor on doc.flexsim.com

XML.Document.loadError

readonly int loadError

Description

The integer value of the error encountered while loading a document.


                XML.Document doc = XML.loadFile("test.xml");
                if (!doc) {
                    return doc.loadError;
                }
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Document.loadErrorName

readonly string loadErrorName

Description

The string name of the error encountered while loading a document.

Here's a list of error names:
  • XML_NO_ERROR
  • XML_NO_ATTRIBUTE
  • XML_WRONG_ATTRIBUTE_TYPE
  • XML_ERROR_FILE_NOT_FOUND
  • XML_ERROR_FILE_COULD_NOT_BE_OPENED
  • XML_ERROR_FILE_READ_ERROR
  • XML_ERROR_ELEMENT_MISMATCH
  • XML_ERROR_PARSING_ELEMENT
  • XML_ERROR_PARSING_ATTRIBUTE
  • XML_ERROR_IDENTIFYING_TAG
  • XML_ERROR_PARSING_TEXT
  • XML_ERROR_PARSING_CDATA
  • XML_ERROR_PARSING_COMMENT
  • XML_ERROR_PARSING_DECLARATION
  • XML_ERROR_PARSING_UNKNOWN
  • XML_ERROR_EMPTY_DOCUMENT
  • XML_ERROR_MISMATCHED_ELEMENT
  • XML_ERROR_PARSING
  • XML_CAN_NOT_CONVERT_TEXT
  • XML_NO_TEXT_NODE

                XML.Document doc = XML.loadFile("test.xml");
                if (!doc) {
                    print("Load Error:", doc.loadErrorName);
                    return doc.loadError;
                }
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Document.root

readonly XML.Element root

Description

Return the root element of the document.


                XML.Document doc = XML.loadFile("test.xml");
                XML.Element root = doc.root;
                ...
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Document.saveAs()

saveAs( string filePath , int compact = 0 )

Parameters

filePath The file path to save your document to.
compact If 1, will only keep required whitespace and newlines. Otherwise, leave it as is.

Description

Saves the XML file to disk. Returns XML_NO_ERROR on success, or an errorID (see loadError above).

You can provide a relative path or an absolute path.

                XML.Document doc;
                ...
                doc.saveAs("test1.xml"); // equivalent to: doc.saveAs(modeldir() + "test1.xml");