我需要解析文件 xml 我有一个显示的链接
<labels>
<label name="name1">
<description name="name1" url="http:............."/>
<description name="name2" url="http:............."/>
</label>
<label name="name2">
<description name="name1" url="http:............."/>
<description name="name2" url="http:............."/>
</label>
<labels>
然后将其显示在列表中。我使用此方法得到 url 的回复,因为 xml 包含
if (reply) {
if (reply->error() == QNetworkReply::NoError) {
int available = reply->bytesAvailable();
if (available > 0) {
int bufSize = sizeof(char) * available + sizeof(char);
QByteArray buffer(bufSize, 0);
int read = reply->read(buffer.data(), available);
response = QString(buffer);
}
} else {
response =
QString("Error: ") + reply->errorString()
+ QString(" status:")
+ reply->attribute(
QNetworkRequest::HttpStatusCodeAttribute).toString();
}
reply->deleteLater();
}
我如何解析它并在列表中显示项目?