Monday, 7 January 2019

Getting xml from ckeditor 5

How do I get the output from ckeditor as xml instead of html?

I thought I could just use editor.data.processor=new XmlDataProcessor(); but that only seems to work for input. So the editor now require xml when calling editor.setData() but editor.getData() still returns html, instead of xml. (The data is not contained in a root element, and img tags are not closed).

The toData method which should convert to xml, is implemented like this which don't look like something which could ever work since it tries to use html htmlWriter to convert to xml. So it just looks like a feature nobody ever implemented.

toData( viewFragment ) {
    // Convert view DocumentFragment to DOM DocumentFragment.
    const domFragment = this._domConverter.viewToDom( viewFragment, document );

    // Convert DOM DocumentFragment to XML output.
    // There is no need to use dedicated for XML serializing method because BasicHtmlWriter works well in this case.
    return this._htmlWriter.getHtml( domFragment );
}



from Getting xml from ckeditor 5

No comments:

Post a Comment