Hi,
I need to output an xml with <a href="...">
But QXmlStreamWriter change it to
<a href="...">
Is there a way to escape those characters?
Thanks!
PS. In fact I am using QXmlStreamWriter to generate an html file....
Hi,
I need to output an xml with <a href="...">
But QXmlStreamWriter change it to
<a href="...">
Is there a way to escape those characters?
Thanks!
PS. In fact I am using QXmlStreamWriter to generate an html file....
Yes, by using QXmlWriter to write the markup for you... Rather than trying to treat it as a dumb stream.
Qt Code:
QXmlStreamWriter w; ... w.writeStartElement("a"); w.writeAtrribute("href", "http://www.qtcentre.org"); w.writeCharacters("Qt Centre"); w.writeEndElement();To copy to clipboard, switch view to plain text mode
The string is passed in. Do I have to wake through each char in the string?
This is the pseudo-code, where text contains "<", ">", """...
Qt Code:
void foo( const QString& text ) { /// writer is somewhere writer.writeCharacters( text ); }To copy to clipboard, switch view to plain text mode
Use the contained device object on the xmlwriter object to write the string(text) converting it to a byte array.
The text is written whithout scaping any characters.
Qt Code:
w.writeStartElement("Value"); w.writeCharacters(""); w.device()->write(text.toByteArray()); w.writeEndElement();To copy to clipboard, switch view to plain text mode
Bookmarks