Skip to content
FutureBlitz

    Install

    Import std.data.xml

    XmlWriter

    std.data.xml

    class

    Public Class XmlWriter

    XmlWriter: XML written a part at a time, each element started, given its attributes, its content written, and ended, in order, into a String that Finish gives. An indent above 0 puts each element on a line of its own, but in an element that holds text, from its first text on, as a writer that goes a part at a time can't know of text to come.

    Examples

    Local writer = XmlWriter()
    writer.StartElement("greeting")
    writer.Attribute("lang", "en")
    writer.Text("hi & bye")
    writer.EndElement()
    Expect(writer.Finish() == "<greeting lang=\"en\">hi &amp; bye</greeting>")

    std/data/xml.fb, line 523

    • @PanicsAtCaller Public New(indent: Int = 0) constructor #

      A writer that indents each element that many spaces for each it's in, or writes them on one line for 0. Panics when indent is negative.

    • @PanicsAtCaller Public Method Declaration() method #

      Writes <?xml version="1.0" encoding="UTF-8"?>. Panics after anything else is written.

    • @PanicsAtCaller Public Method StartElement(name: String) method #

      Starts an element named name. Panics when name isn't an XML name, or the root element has ended.

    • @PanicsAtCaller Public Method Attribute(name: String, value: String) method #

      Gives the element just started an attribute. Panics when name isn't an XML name, it isn't right after the start or another attribute, the element has an attribute of that name already, or value holds a character XML hasn't got.

    • @PanicsAtCaller Public Method Text(text: String) method #

      Writes text in the open element. Panics outside one, or when text holds a character XML hasn't got.

    • @PanicsAtCaller Public Method CData(text: String) method #

      Writes a CDATA section of text in the open element, one more each time text holds "]]>", whose "]]" ends one and '>' starts the next. Panics outside an element, or when text holds a character XML hasn't got.

    • @PanicsAtCaller Public Method Comment(text: String) method #

      Writes a comment. Panics when text holds "--", ends with '-', or holds a character XML hasn't got.

    • @PanicsAtCaller Public Method Instruction(target: String, text: String) method #

      Writes a processing instruction. Panics when target isn't an XML name or is xml, or text holds "?>" or a character XML hasn't got.

    • @PanicsAtCaller Public Method EndElement() method #

      Ends the open element, as <name/> when it's empty. Panics when none is open.

    • @PanicsAtCaller Public Method Finish(): String method #

      What was written. Panics when an element is open, or none was written.

    Report an issue with this page or with FutureBlitz on GitHub.