$k. XMLWriter

new XMLWriter(documentopt, optionsopt)

Creates a new XML writer

Parameters:
NameTypeAttributesDescription
document$k.AbstractTextDocument<optional>

Document to write on. A new text document will be created if not specified

optionsobject<optional>

Options

  • invalidCharacters: {boolean} True if invalid characters should be exported as numeric entities. False if invalid characters should be skipped.
  • indent {boolean} Enable/disable automatic indentation of the XML tags
  • charMap {object} Map of characters (string of length 1) to replacement strings. When writing text, all matching characters will be replaced with these strings.

SAX interface for writing XML. An XMLWriter is created by sending xmlWriter() to a document.

Version
  • Experimental feature, might be removed at any time
Since
  • 4.3.1

Methods

attribute(localName, value, prefixopt)

Writes an attribute of a tag to the document

Parameters:
NameTypeAttributesDescription
localNamestring

Local name of the attribute

valuestring

Value of the attribute

prefixstring<optional>

Namespace prefix. The writer does not check if it is bound to a namespace

Throws:

If writing the attribute is not possible

Type
$k.exception.XMLError

cdata(characters)

Writes a CDATA section to the document

Parameters:
NameTypeDescription
charactersstring
Throws:

If writing the CData is not possible

Type
$k.exception.XMLError

characters(characters)

Writes a string to the document

Parameters:
NameTypeDescription
charactersstring
Throws:

If writing the string is not possible

Type
$k.exception.XMLError

comment(comment)

Writes a comment to the document

Parameters:
NameTypeDescription
commentstring
Throws:

If writing the comment is not possible

Type
$k.exception.XMLError

defaultNamespace(namespace)

Write the default namespace of the current tag and its children

Parameters:
NameTypeDescription
namespacestring
Throws:

If writing the namespace is not possible

Type
$k.exception.XMLError

document() → {$k.AbstractTextDocument}

Returns the document

Version
  • Experimental feature, might be removed at any time
Since
  • 4.3.1

endElement()

Closes the currently opened tag

Throws:

If closing the tag is not possible

Type
$k.exception.XMLError

print(characters)

Writes a string to the document without any escaping

Parameters:
NameTypeDescription
charactersstring
Throws:

If writing the string is not possible

Type
$k.exception.XMLError

processingInstruction(target, data)

Writes a processing instruction to the document

Parameters:
NameTypeDescription
targetstring
datastring
Throws:

If writing the comment is not possible

Type
$k.exception.XMLError

setIndent(enableIndentation)

Enable/disable automatic indentation of the XML tags. Default is true

Parameters:
NameTypeDescription
enableIndentationboolean

setPrefix(prefix, namespace)

Sets the prefix the uri is bound to

Parameters:
NameTypeDescription
prefixstring
namespacestring

startElement(localName, prefixopt)

Writes a start tag to the document

Parameters:
NameTypeAttributesDescription
localNamestring

Local name of the tag

prefixstring<optional>

Namespace prefix. The writer does not check if it is bound to a namespace

Throws:

If writing the tag is not possible

Type
$k.exception.XMLError