Skip to content

Attribute

Adds a new attribute with the specified name and value to current element.

1
myXmlWriter.Attribute(name: string, value: ( string | number | boolean | DateTimeOffset )):XmlWriter

Parameters

string name
    name of attribute

( string | number | boolean | DateTimeOffset ) value
    value of attribute

Remarks

This method adds a new attribute with the specified name and value to the current element and returns the current writer instance.
value is encoded with XML encoding rules.

Example

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

See Also