XmlWriter.Attribute

Overview

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

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

Arguments

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

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

Copyright © 2010 - 2023 Emakin. All rights reserved.