# XmlDataProcessor

class

The XML data processor class. This data processor implementation uses XML as input and output data. This class is needed because unlike HTML, XML allows to use any tag with any value. For example, `<link>Text</link>` is a valid XML but invalid HTML.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L27)

<a id="properties">

## Properties

<a id="member-domConverter">

### `domConverter: ViewDomConverter`

DOM converter used to convert DOM elements to view elements.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L44)

<a id="member-domParser">

### `domParser: DOMParser`

DOM parser instance used to parse an XML string to an XML document.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L39)

<a id="member-htmlWriter">

### `htmlWriter: DataProcessorHtmlWriter`

A basic HTML writer instance used to convert DOM elements to an XML string. There is no need to use a dedicated XML writer because the basic HTML writer works well in this case.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L50)

<a id="member-namespaces">

### `namespaces: Array<string>`

A list of namespaces allowed to use in the XML input.

For example, registering namespaces \[ 'attribute', 'container' ] allows to use `<attirbute:tagName></attribute:tagName>` and `<container:tagName></container:tagName>` input. It is mainly for debugging.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L34)

<a id="member-skipComments">

### `skipComments: boolean`

If `false`, comment nodes will be converted to `$comment`. Otherwise comment nodes are ignored.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L52)

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( document, options = { options.namespaces? } )`

Creates a new instance of the XML data processor class.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L61)

#### Parameters

* `document: ViewDocument`

  The view document instance.

* `options: object`

  Configuration options.

  Properties

  * `options.namespaces?: Array<string>`

    A list of namespaces allowed to use in the XML input.

  Defaults to `{}`

<a id="function-registerRawContentMatcher">

### `registerRawContentMatcher( pattern ) → void`

Registers a [`MatcherPattern`](module_engine_view_matcher-MatcherPattern.md) for view elements whose content should be treated as raw data and not processed during the conversion from XML to view elements.

The raw data can be later accessed by a [custom property of a view element](module_engine_view_element-ViewElement.md#function-getCustomProperty) called `"$rawContent"`.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L112)

#### Parameters

* `pattern: MatcherPattern`

  Pattern matching all view elements whose content should be treated as raw data.

#### Returns

* `void`

<a id="function-toData">

### `toData( viewFragment ) → string`

Converts the provided [document fragment](module_engine_view_documentfragment-ViewDocumentFragment.md) to data format – in this case an XML string.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L74)

#### Parameters

* `viewFragment: ViewDocumentFragment`

#### Returns

* `string`

  An XML string.

<a id="function-toView">

### `toView( data ) → ViewDocumentFragment`

Converts the provided XML string to a view tree.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L89)

#### Parameters

* `data: string`

  An XML string.

#### Returns

* `ViewDocumentFragment`

  A converted view element.

<a id="function-useFillerType">

### `useFillerType( type ) → void`

If the processor is set to use marked fillers, it will insert `&nbsp;` fillers wrapped in `<span>` elements (`<span data-cke-filler="true">&nbsp;</span>`) instead of regular `&nbsp;` characters.

This mode allows for a more precise handling of block fillers (so they do not leak into editor content) but bloats the editor data with additional markup.

This mode may be required by some features and will be turned on by them automatically.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L127)

#### Parameters

* `type: 'default' | 'marked'`

  Whether to use the default or the marked `&nbsp;` block fillers.

#### Returns

* `void`

<a id="function-_toDom">

### `_toDom( data ) → DocumentFragment` _(private)_

Converts an XML string to its DOM representation. Returns a document fragment containing nodes parsed from the provided data.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.ts#L135)

#### Parameters

* `data: string`

#### Returns

* `DocumentFragment`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
