Class: tinymce.dom.StringWriter

# tinymce.dom.StringWriter

Namespace | tinymce.dom
Class | StringWriter

This class writes nodes into a string.

## Public Methods

Method | Defined By
--- | ---
StringWriter(s:Object) Constructs a new StringWriter. | StringWriter
encode(s:String):String String writer specific method. | StringWriter
getContent():String Returns a string representation of the elements/nodes written. | StringWriter
reset():void Resets the writer so it can be reused the contents of the writer is cleared. | StringWriter
writeAttribute(n:String, v:String):void Writes an attrubute like for example: myattr="valie" | StringWriter
writeCDATA(v:String):void Writes a CDATA section. | StringWriter
writeComment(v:String):void Writes a comment. | StringWriter
writeEndElement():void Write the end of a element. | StringWriter
writeFullEndElement():void Writes the end of a element. | StringWriter
writeRaw(v:String):void String writer specific function. | StringWriter
writeStartElement(n:String):void Writes the start of an element like for example: <tag. | StringWriter
writeText(v:String):void Writes a text node value. | StringWriter

## Method details

### StringWriterconstructor

`public function StringWriter(s:Object)`
Constructs a new StringWriter.

#### Parameters

s:Object | Optional settings object.

### encodemethod

`public function encode(s:String):String`
String writer specific method. This encodes the raw entities of a string.

#### Parameters

s:String | String to encode.

#### Returns

String - String with entity encoding of the raw elements like <>&".

### getContentmethod

`public function getContent():String`
Returns a string representation of the elements/nodes written.

#### Returns

String - String representation of the written elements/nodes.

### resetmethod

`public function reset():void`
Resets the writer so it can be reused the contents of the writer is cleared.

### writeAttributemethod

`public function writeAttribute(n:String, v:String):void`
Writes an attrubute like for example: myattr="valie"

#### Parameters

n:String | Attribute name to write.
v:String | Attribute value to write.

### writeCDATAmethod

`public function writeCDATA(v:String):void`
Writes a CDATA section.

#### Parameters

v:String | Value to write in CDATA.

### writeCommentmethod

`public function writeComment(v:String):void`
Writes a comment.

#### Parameters

v:String | Value of the comment.

### writeEndElementmethod

`public function writeEndElement():void`
Write the end of a element. This will add a short end for elements with out children like for example a img element.

### writeFullEndElementmethod

`public function writeFullEndElement():void`
Writes the end of a element. This will add a full end to the element even if it didn't have any children.

### writeRawmethod

`public function writeRaw(v:String):void`
String writer specific function. Enables you to write raw contents to the string.

#### Parameters

v:String | String with raw contents to write.

### writeStartElementmethod

`public function writeStartElement(n:String):void`
Writes the start of an element like for example:

#### Parameters

n:String | Name of element to write.

### writeTextmethod

`public function writeText(v:String):void`
Writes a text node value.

#### Parameters

v:String | Value to append as a text node.