Skip to content

Xml

Writes the given XML content as a child element of the current element.

1
myXmlWriter.Xml(value: ( string | Xml )):XmlWriter

Writes the given XML content as a child element with the specified element name.

1
myXmlWriter.Xml(elementName: string, value: ( string | Xml )):XmlWriter

Parameters

( string | Xml ) value
    XML content to write. This can be an Xml instance or an XML string.

string elementName
    Name of the element to create as a child.

Returns

The current XmlWriter instance, allowing for method chaining. The current XmlWriter instance, allowing for method chaining.

Remarks

This method writes the specified XML content as a direct child of the current element. The provided XML is inserted directly without further encoding.

Example

1
2
3
4
5
6
var writer = $Xml.Create();
writer.StartElement('Customer');
writer.Xml('<Name>Doe</Name>');
writer.EndElement();
var xml = writer.ToXml();
// xml: <Customer><Name>Doe</Name></Customer>

This method creates a new element with the specified name and inserts the given XML content within that element. The provided XML is inserted directly without further encoding.

Example

1
2
3
4
var writer = $Xml.Create();
writer.Xml('Customer', '<Name>Doe</Name>');
var xml = writer.ToXml();
// xml: <Customer><Name>Doe</Name></Customer>

See Also