View Full Version : Generate encoding code..
dark1988
30th July 2008, 09:50
How to generate <?xml version="1.0" encoding="UTF-8" standalone="0" ?> in xml using Dom or XMLStreamWriter????:confused:
Can i have a sample of it.. thanks...
Cos i don noe how to code the part...
aamer4yu
30th July 2008, 10:37
You can add it before setting content,,,
like if u have xml data in xmlData,
you can write - xmlData.prepend("<?xml version="1.0" encoding="UTF-8" standalone="0" ?>");
and then write to QDomDocument.
dark1988
30th July 2008, 10:42
thanks... for xmlData need any lib???
dark1988
30th July 2008, 10:54
xmlData is the file or xml??
is it QXmlStreamWriter xmlData;
xmlData.prepend("<?xml .. .. .. ?>");
aamer4yu
30th July 2008, 11:17
xmlData is ur QString.
refere QDomDocument::setContent()
dark1988
31st July 2008, 03:31
Im almost getting correct. can i ask how to insert the QString into the first line of the xml file??
Is it using the "insertBefore(newValue,referValue);" ??
See QDomDocument::createProcessingInstruction():
QDomDocument doc;
QDomProcessingInstruction pi = doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" standalone=\"0\"");
doc.appendChild(pi);
qDebug() << doc.toString();
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.