while xml atEnd qDebug XML returned xml text toString xml readNext if

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
while (!xml.atEnd()) {
//qDebug() << "XML returned:" << xml.text().toString();
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
publisher.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
publisher.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("registrationurl")) {
publisher.setUrl(xml.readElementText());
} else if (xml.name() == QLatin1String("fields")) {
while (!xml.atEnd()) {
xml.readNextStartElement();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("field")) {
Field t;
while (!xml.atEnd()) {
xml.readNextStartElement();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("fieldtype")) {
t.type = xml.readElementText();
} else if (xml.name() == QLatin1String("name")) {
t.name = xml.readElementText();
} else if (xml.name() == QLatin1String("fieldsize")) {
t.fieldsize = xml.readElementText().toInt();
} else if (xml.name() == QLatin1String("required")) {
t.required = xml.readElementText() == QLatin1String("true");
} else if (xml.name() == QLatin1String("options")) {
while (!xml.atEnd()) {
xml.readNextStartElement();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("option")) {
t.options << xml.readElementText();
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("options")) {
xml.readNext();
break;
}
}
}
} else if (xml.isEndElement() && (xml.name() == QLatin1String("field"))) {
xml.readNext();
break;
}
}
publisher.addField(t);
}
} else if (xml.isEndElement() && (xml.name() == QLatin1String("fields"))) {
xml.readNext();
break;
}
}
} else if (xml.name() == QLatin1String("supportedtargets")) {
while (!xml.atEnd()) {
xml.readNextStartElement();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("target")) {
Target t;
t.name = xml.readElementText();
publisher.addTarget(t);
}
} else if (xml.isEndElement() && (xml.name() == QLatin1String("supportedtargets"))) {
xml.readNext();
break;
}
}
}
} else if (xml.isEndElement()
&& ((xml.name() == QLatin1String("publisher"))
|| (xml.name() == QLatin1String("user")))) {
break;
}
}