v2026.6.4
All Bundles
Bundle XML parsing and building library. XmlParser reads XML into an XmlElement tree with attribute and child-node navigation; XmlBuilder constructs XML documents. Compile with -lib xml.

XmlBuilder

Used to programmatically build XML documents

Example

builder := XmlBuilder->New("root");
builder->AddTextElement("name", "John");
builder->AddTextElement("age", "30");
builder->ToString()->PrintLine();

Operations

GetEncoding #

Gets the XML encoding

method : public : GetEncoding() ~ String

Return

TypeDescription
StringXML encoding

Example

builder := XmlBuilder->New("root", "1.0", "UTF-8");
builder->GetEncoding()->PrintLine();

GetRoot #

Returns the root node of the XML document

method : public : GetRoot() ~ XmlElement

Return

TypeDescription
XmlElementroot node

Example

builder := XmlBuilder->New("items");
root := builder->GetRoot();
root->SetContent("hello");
builder->ToString()->PrintLine();

GetVersion #

Gets the XML version

method : public : GetVersion() ~ String

Return

TypeDescription
StringXML version

Example

builder := XmlBuilder->New("root", "1.0");
builder->GetVersion()->PrintLine();

New # constructor

Default constructor

New(name:String)

Parameters

NameTypeDescription
nameStringroot element name

Example

builder := XmlBuilder->New("catalog");
builder->GetRoot()->AddChild(XmlElement->New(XmlElement->Type->ELEMENT, "book"));
builder->ToString()->PrintLine();

New # constructor

Default constructor

New(name:String, version:String)

Parameters

NameTypeDescription
nameStringroot element name
versionStringXML version tag

Example

builder := XmlBuilder->New("root", "1.0");
builder->ToString()->PrintLine();

New # constructor

Default constructor

New(name:String, version:String, encoding:String)

Parameters

NameTypeDescription
nameStringroot element name
versionStringXML version tag
encodingStringXML encoding type

Example

builder := XmlBuilder->New("root", "1.0", "UTF-8");
builder->ToString()->PrintLine();

SetEncoding #

Sets the XML encoding

method : public : SetEncoding(encoding:String) ~ Nil

Parameters

NameTypeDescription
encodingStringencoding version

Return

TypeDescription
NilXML encoding

Example

builder := XmlBuilder->New("root", "1.0");
builder->SetEncoding("UTF-8");
builder->GetEncoding()->PrintLine();

SetVersion #

Sets the XML version

method : public : SetVersion(version:String) ~ Nil

Parameters

NameTypeDescription
versionStringversion

Return

TypeDescription
NilXML version

Example

builder := XmlBuilder->New("root");
builder->SetVersion("1.1");
builder->GetVersion()->PrintLine();

ToString #

Produces an XML string representation of the document

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation of the document

Example

builder := XmlBuilder->New("root", "1.0", "UTF-8");
child := XmlElement->New(XmlElement->Type->ELEMENT, "name");
child->SetContent("Alice");
builder->GetRoot()->AddChild(child);
builder->ToString()->PrintLine();