Skip to content

XML API

Nenkai edited this page Jul 14, 2024 · 3 revisions

Warning

This API was introduced after GT4.

XML Parsing

// Load xml from source
var xml = main::pdistd::MXml();
xml.parse(xml_data);

// Navigate/Iterate through nodes
var dom = xml.result;
var xml_nodes = dom[node_name];
foreach (var node in xml_nodes)
{
    // ...
}

XML Serialization

var xml_node = pdistd::MDomNode();
// xml_node.addNode(name, node);
// xml_node.addAttribute(name, node);

var xml_head = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n";
var xml_data = xml_node.serialize("xml");
var xml_str = xml_head + xml_data;
Clone this wiki locally