I wrote this in a browser, but I'm sure that this code works fine. 
QFile file("phones.xml");
return;
if (!doc.setContent(&file)) {
file.close();
return;
}
file.close();
while(!n.isNull()) {
if(!e.isNull()) {
if (e.tagName() == "phone") {
qDebug() << "location" << e.attribute("location");
qDebug() << "value" << e.attribute("value");
} else if (e.tagName() == "settings") {
qDebug() << "AfterHourOffset" << e.attribute("AfterHourOffset");
qDebug() << "NumPerButton" << e.attribute("NumPerButton");
qDebug() << "MaxNumToDial" << e.attribute("MaxNumToDial");
}
}
n = n.nextSibling();
}
QDomDocument doc;
QFile file("phones.xml");
if (!file.open(QIODevice::ReadOnly))
return;
if (!doc.setContent(&file)) {
file.close();
return;
}
file.close();
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
while(!n.isNull()) {
QDomElement e = n.toElement();
if(!e.isNull()) {
if (e.tagName() == "phone") {
qDebug() << "location" << e.attribute("location");
qDebug() << "value" << e.attribute("value");
} else if (e.tagName() == "settings") {
qDebug() << "AfterHourOffset" << e.attribute("AfterHourOffset");
qDebug() << "NumPerButton" << e.attribute("NumPerButton");
qDebug() << "MaxNumToDial" << e.attribute("MaxNumToDial");
}
}
n = n.nextSibling();
}
To copy to clipboard, switch view to plain text mode
Bookmarks