【发布时间】:2012-08-08 17:11:21
【问题描述】:
当我将QDomDocument 用于HTML 内容时,如果文档开头有<!doctype html>,则无法设置内容。但实际上为什么呢?!
例如考虑下面的sn-p代码:
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();
这段代码的输出只有falses 的列表!
【问题讨论】:
标签: qt dom html-parsing doctype qtxml