i wand to write xml doc on QDomDocument not entyti ....
on line to line the doc is so:
xml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
xml.append("<cms:root xmlns:cms=\"http://www.pulitzer.ch/2005/PuliCMS/1.0\">");
xml.append("<cms:page la=\"it\">");
xml.append(desc_it->GetXMLTag());
xml.append("</cms:page>");
xml.append("</cms:root>");
qDebug() << "### xml result1 " << stayutf8;
QStringList xml;
xml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
xml.append("<cms:root xmlns:cms=\"http://www.pulitzer.ch/2005/PuliCMS/1.0\">");
xml.append("<cms:page la=\"it\">");
xml.append(desc_it->GetXMLTag());
xml.append("</cms:page>");
xml.append("</cms:root>");
QString stayutf8 = xml.join("\n");
qDebug() << "### xml result1 " << stayutf8;
To copy to clipboard, switch view to plain text mode
and on a real QDomDocument.... Manual say so:
root.setAttribute("xmlns:s","http://www.pulitzer.ch/2005/shop/shema/1.0/");
root.setAttribute("xmlns:cms","http://www.pulitzer.ch/2005/PuliCMS/1.0/");
doc.appendChild(root);
page.setAttribute("xmlns:cms","http://www.pulitzer.ch/2005/PuliCMS/1.0/");
page.setAttribute("la","it");
root.appendChild(page);
qDebug() << "### xml result2 " << xml;
QDomDocument doc(QDomImplementation::createDocument(QString("http://www.pulitzer.ch/2005/PuliCMS/1.0/"),
QString("utf8"),(const QDomDocumentType)"xml"));
QDomElement root = doc.createElement("root");
root.setAttribute("xmlns:s","http://www.pulitzer.ch/2005/shop/shema/1.0/");
root.setAttribute("xmlns:cms","http://www.pulitzer.ch/2005/PuliCMS/1.0/");
doc.appendChild(root);
QDomElement page = doc.createElement("cms:page");
page.setAttribute("xmlns:cms","http://www.pulitzer.ch/2005/PuliCMS/1.0/");
page.setAttribute("la","it");
page.appendChild((const QDomDocumentFragment)(desc_it->GetXMLTag()));
root.appendChild(page);
QString xml = doc.toString();
qDebug() << "### xml result2 " << xml;
To copy to clipboard, switch view to plain text mode
on php5 and qt all dom function is same but new domdocument no....
php = $dom = new DOMDocument('1.0', 'utf-8') and become a clean first line...
qt no why?
how to become a clean line <?xml version=\"1.0\" encoding=\"utf-8\"?> so tidy xml dont clean?
Bookmarks