| CRM64Pro GDK v0.19.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
XML
Core modules

## Description

XML Manager and XML objects providing a full parsing system [v26.02.0].

### Overview

The XML module provides a complete XML parsing system through the XML Manager and XML objects. Objects can be loaded from external XML files or created programmatically on the fly.

### Key features

- File loading: Parse and load XML documents from external files
- Dynamic creation: Build XML structures programmatically at runtime
- Stateful navigation: Each object maintains an internal state with current node pointer and navigation context
- Standard manager: Unique object management using name as the key

### Internal state

Each XML object maintains an internal state containing important variables such as the current node pointer. This state is modified during navigation and query operations.

Single-threaded | Safe to use without restrictions
Multi-threaded | Concurrent access to the same object may cause unexpected results due to shared internal state

### Concurrency workaround

For read-only concurrent access from multiple threads, duplicate the object:

1. Load the XML object
2. Change its name
3. Load the same XML file again with the original name

This creates two independent objects with separate internal states, allowing safe read-only concurrency.

### Manager type

This is a standard manager: objects are not shared and must be unique using its name as the key. You cannot create an object with the same name as another one already created.

### Naming security

Resource names are restricted to prevent collisions with system assets. The characters '#' and '@' are reserved for internal engine use. Any attempt to create or rename a resource starting with these characters will be rejected (returning a negative error code).

### Best practices

- Be mindful of the internal state when accessing the same object from different functions
- Avoid concurrent access to the same XML object from multiple threads
- Use the duplication workaround when read-only multi-threaded access is required
- Ensure each object has a unique name before creation or loading
- Access the manager exclusively through Main::xmlMgr()

Note
  The XML Manager is a singleton, automatically created once Main is instantiated. You can get a reference to this manager using Main::xmlMgr() method.
  The XML Manager is automatically released when Main::terminate() is called. At this time, any resource still loaded will be released, avoiding resource leaks.

## Classes
class | CRM64Pro::XML
| XML Object class. More...
class | CRM64Pro::XMLMgr
| XML Manager class. More...