PDA

View Full Version : Qt Xml QDomDocument Special character handling



Prady_80
6th November 2013, 14:06
Hi,

I have QString which contains XML data that is obtained from a remote system.
The problem with this data is that the special characters are not translated. for example & is not translated to &amp.
When I try to parse this xml using QDomDocument's setContent method, I experience a failure.

Does Qt Xml handling any how have the facility of escaping such characters or replacing them with the translated characters so that the Xml document becomes a valid document?

Any help is greatly appreciated.
Thanks

Edit: Please note that I cannot change the data format that I am receiving as the remote system is not under my control, so CDATA option is not available.

anda_skoa
6th November 2013, 15:47
As a starting point:
Qt4: http://doc.qt.digia.com/4.7/qt.html#escape
Qt5: http://qt-project.org/doc/qt-5.0/qtcore/qstring.html#toHtmlEscaped

But probably doing more than what you want

Cheers,
_