XMLWriter.closeStartTag

Writes the end of a start tag to the ouput range.

It is an error to call closeStartTag unless a start tag has been opened and not yet closed.

struct XMLWriter(OR)
void
closeStartTag
if (
isOutputRange!(OR, char)
)

Parameters

emptyTag
Type: EmptyTag

Whether the start tag will be empty (i.e. terminated with "/>" so that there is no corresponding end tag).

Examples

1 import std.array : appender;
2 
3 auto writer = xmlWriter(appender!string());
4 
5 writer.openStartTag("root", Newline.no);
6 assert(writer.output.data == "<root");
7 
8 writer.closeStartTag();
9 assert(writer.output.data == "<root>");
10 
11 writer.openStartTag("foo");
12 assert(writer.output.data ==
13        "<root>\n" ~
14        "    <foo");
15 
16 writer.closeStartTag(EmptyTag.yes);
17 assert(writer.output.data ==
18        "<root>\n" ~
19        "    <foo/>");
20 
21 writer.writeEndTag();
22 assert(writer.output.data ==
23        "<root>\n" ~
24        "    <foo/>\n" ~
25        "</root>");

See Also

Meta