[#BloombergLP-balxml-Formatter-addAttribute]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balxml.adoc[balxml]::xref:BloombergLP/balxml/Formatter.adoc[Formatter]::addAttribute
:relfileprefix: ../../../
:mrdocs:

Add an attribute of the specified `name` and `value` to the currently open element&period;

== Synopsis

Declared in `&lt;balxml&lowbar;formatter&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
void
addAttribute(
    std::string&lowbar;view const& name,
    TYPE const& value,
    int formattingMode = 0);
----

== Description

`value` can be of the following types&colon; `char`, `short`, `int`, `bsls&colon;&colon;Types&colon;&colon;Int64`, `float`, `double`, `bsl&colon;&colon;string`, `bdlt&colon;&colon;Datetime`, `bdlt&colon;&colon;Date`, and `bdlt&colon;&colon;Time`&period; Precede this name&equals;&quot;value&quot; pair with a single space&period; Wrap line (write the attribute on next line with proper indentation), if the length of name&equals;&quot;value&quot; is too long&period; Optionally specify a `formattingMode` used to control the formatting of the `value`&period; If `value` is of type `bsl&colon;&colon;string` or convertible to `bsl&colon;&colon;string&lowbar;view`, the presence of invalid input stops the transfer of data to the output specified on construction (see &lcub;Valid Strings&rcub;)&period; If `value` is of type `bsl&colon;&colon;string` or convertible to `bsl&colon;&colon;string&lowbar;view`, any special characters in `value` are escaped (see &lcub;Special Characters&rcub;)&period; If `value` is of type `char`, it is cast to a signed byte value with a range `&lsqb; &hyphen;128 &period;&period; 127 &rsqb;`&period; The behavior is undefined unless the last manipulator was `openElement` or `addAttribute`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *name*
| name of the attribute
| *value*
| value of the attribute
| *formattingMode*
| mode used to format `value`
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
