Skip to content

XMLDocument

Bases: object

XMLDocument class represents an entire XML document

Notes: This class is non-copyable and non-movable.

This class handles loading and saving of XML documents and access to the root node.

__init__()

Default constructor

loadFile(xmlFile)

Load from file

Loads the XML document from a file path.

Parameters:

Name Type Description Default
xmlFile string

The path to the XML file

required

Raises:

Type Description
InscoperException

If an error occurs during loading

tryLoadingFile(xmlFile)

Try loading from file

Attempts to load the XML document without throwing an exception.

Parameters:

Name Type Description Default
xmlFile string

The path to the XML file

required

Returns:

Type Description
boolean

True if loading was successful, false otherwise

saveFile(xmlFile)

Save to file

Saves the current XML document to a file.

Parameters:

Name Type Description Default
xmlFile string

The path where the XML file will be saved

required

Raises:

Type Description
InscoperException

If an error occurs during saving

getChild(name)

Get child node by name

Retrieves a direct child node with the name.

Parameters:

Name Type Description Default
name string

The name of the child node

required

Returns:

Type Description
XMLNode

The child XML node

toXMLNode()

Convert to XML node

Returns the root element of the document as an XML node.

Returns:

Type Description
XMLNode

The root XML node