【发布时间】:2016-01-18 12:34:37
【问题描述】:
我有像这样解析 XML 的成员函数:
void xmlparser::parsingFunction()
{
while(1)
{
QFile file("info.xml");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug("Failed to open file for reading");
}
QDomDocument document;
if(!document.setContent(&file))
{
qDebug("Failed to parse the file into a Dom tree");
file.close();
}
file.close();
QDomElement documentElement = document.documentElement();
QDomNode node = documentElement.firstChildElement();
while(!node.isNull())
{
if(node.isElement())
{
QDomElement first = node.toElement();
emit xmlParsed(first.tagName());
sleep(5);
}
node.nextSibling();
}
}
}
我的 xml 树看起来像这样 http://pastebin.com/nFMJKcmU
我不知道为什么它没有在根元素信息中显示所有可用的标签
【问题讨论】:
标签: c++ xml qt xml-parsing