Class: XMLManager

XMLManager(options)

Manages operations related to XML files, including parsing, loading, and saving.

Constructor

new XMLManager(options)

Creates an instance of XMLManager.

Parameters:
Name Type Description
options Object

Configuration options for XMLManager.

Properties
Name Type Description
fullPath string

The full path to the XML file.

outputFileName string

The name of the output XML file (optional).

Source:

Members

fullPath :string

The full path to the XML file.

Type:
  • string
Source:

fullPathArray :Array

The array containing individual parts of the full path.

Type:
  • Array
Source:

inputFileName :string

The input file name extracted from the full path.

Type:
  • string
Source:

outputFileName :string

The name of the output XML file.

Type:
  • string
Source:

Methods

(async) getFile(filePathopt) → {Promise.<(string|Error)>}

Reads the content of the specified file path.

Parameters:
Name Type Attributes Description
filePath string <optional>

The path to the file to be read (optional, uses the instance's fullPath if not provided).

Source:
Returns:
  • A promise that resolves with the file content or an Error object if reading fails.
Type
Promise.<(string|Error)>

(async) getParsedXML(pathopt) → {Promise.<(Object|Error)>}

Retrieves and parses the XML file located at the specified path.

Parameters:
Name Type Attributes Description
path string <optional>

The path to the XML file (optional, uses the instance's fullPath if not provided).

Source:
Returns:
  • A promise that resolves with the parsed XML object or an Error object if parsing fails.
Type
Promise.<(Object|Error)>

(async) parseFile(stringData) → {Promise.<(Object|Error)>}

Parses the given XML string into an object.

Parameters:
Name Type Description
stringData string

The XML string to be parsed.

Source:
Returns:
  • A promise that resolves with the parsed XML object or an Error object if parsing fails.
Type
Promise.<(Object|Error)>

(async) saveFile(obj, pathopt) → {Promise.<(string|Error)>}

Saves the given object as an XML file at the specified path.

Parameters:
Name Type Attributes Description
obj Object

The object to be converted and saved as XML.

path string <optional>

The path where the XML file will be saved (optional, uses the instance's fullPath if not provided).

Source:
Returns:
  • A promise that resolves with the saved XML content or an Error object if saving fails.
Type
Promise.<(string|Error)>