QDomDocument fails to set content of an HTML document with <!doctype> tag

Viewed 3168

When I use QDomDocument with HTML content, it fails to set content if there is a <!doctype html> at the beginning of the document. But actually why?! for example consider the following snippet of code:

 QDomDocument doc;
 QString content = "<!doctype html><html><body><a href='bar'>foo</a></body></html>";
 qDebug() << doc.setContent(content,false,0,0);
 QDomElement docElem = doc.documentElement();
 QDomNode a = docElem.firstChild();
 qDebug() << doc.childNodes().size() << docElem.childNodes().size();

nothing but a list of falses are the output of this code!

2 Answers
Related