Skip to content

Xml Serializer

Spice
import "std/text/xml-serializer";

XmlSerializer struct

Serializer for XML output.

Elements without children are written as self-closing tags. Text content and attribute values are escaped with the predefined entities, so the result round-trips through parseXml from "std/text/xml-parser".

In pretty mode, elements that contain child elements are laid out with two-space indentation, one node per line; elements containing only text are kept on a single line.

Constructors

ctor

Spice
public p XmlSerializer.ctor(bool pretty = false)

Construct an XML serializer

Parameters

Name Type Description
pretty bool Emit human-readable output with two-space indentation (default: false)

Methods

serialize

Spice
public f<String> XmlSerializer.serialize(XmlNode& node)

Serializes an XML node into an XML string

Parameters

Name Type Description
node XmlNode& XML node to serialize

Returns: String — XML representation

serialize

Spice
public f<String> XmlSerializer.serialize(XmlNode* node)

Serializes an XML node into an XML string

Parameters

Name Type Description
node XmlNode* XML node to serialize

Returns: String — XML representation