Я пытаюсь проанализировать QString, которая выглядит следующим образом:
<unit>
<unit_type>110A</unit_type>
<manufacturer>ABC</manufacturer>
<article_number>9900</article_number>
<production_date>2008-05-29</production_date>
<delivery_revision>03B</delivery_revision>
<present_revision>03B</present_revision>
<rev_date>2008-05-29</rev_date>
<made_the_last_rev>B21</made_the_last_rev>
<serial_number>530029</serial_number>
<eth_addresses>
<eth_address>00:06:30:03:0c:0b</eth_address>
</eth_addresses>
<boards>
<board>
<board_type>411C</board_type>
<article_number>9910</article_number>
<production_date>2008-05-29</production_date>
<delivery_revision>01A</delivery_revision>
<present_revision>01A</present_revision>
<rev_date>2008-05-29</rev_date>
<made_the_last_rev>B21</made_the_last_rev>
<serial_number>0460044</serial_number>
</board>
<board>200Z4
<board_type>731A</board_type>
<article_number>3-474</article_number>
<serial_number>200Z4</serial_number>
</board>
<board>
<board_type>401B</board_type>
<article_number>04418</article_number>
<production_date>2008-05-28</production_date>
<delivery_revision>01B</delivery_revision>
<present_revision>01B</present_revision>
<rev_date>2008-05-28</rev_date>
<made_the_last_rev>B21</made_the_last_rev>
<serial_number>1370017</serial_number>
</board>
</boards>
</unit>
<unit2 version="1" release="0" update="0" evolution="0" >
<unit_type>4533</unit_type>
<manufacturer>AH</manufacturer>
<article_number>34030</article_number>
<production_date>2017-07-27</production_date>
<delivery_revision>01A</delivery_revision>
<present_revision>P2</present_revision>
<rev_date>2017-07-27</rev_date>
<made_the_last_rev>CH</made_the_last_rev>
<serial_number>300000042</serial_number>
<eth_addresses>
<eth_address>C0:35:80:00:10:96</eth_address>
<eth_address>C0:35:80:00:10:97</eth_address>
</eth_addresses>
<boards>
<board>
<board_type>MAINBOARD</board_type>
<article_number>0BEDR</article_number>
<production_date>2017-07-19</production_date>
<serial_number>2626</serial_number>
</board>
<board>
<board_type>TIO</board_type>
<article_number>00SMDTOP</article_number>
<production_date>2017-07-15</production_date>
<serial_number>0599</serial_number>
</board>
<board>
<board_type>TFT</board_type>
<article_number>MTI-HL</article_number>
<production_date>2017-07-10</production_date>
<serial_number>31307</serial_number>
</board>
Моя функция выглядит так:
void VrsRequesterWrapper::parseHardwareData(QString pData)
{
qDebug() << " parseHardwareData ";
QXmlStreamReader reader(pData);
qDebug() << " first Item #1" << reader.name();
if(reader.readNextStartElement())
{
qDebug() << " first Item #2" << reader.name();
while(reader.name() == "unit2") {
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #1 " << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #2" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #3" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #4" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #5" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #6" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #7" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #8" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE #9" << reader.name();
reader.skipCurrentElement();
}
qDebug() << "DATA VALUE #10" << reader.name();
while(reader.readNextStartElement()){
if(reader.name() == "eth_addresses"){
while(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Ethernet #1" << reader.name();
reader.skipCurrentElement();
}
}
}
qDebug() << "DATA VALUE Board while #1" << reader.name();
while(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Board while #2" << reader.name();
if(reader.name() == "boards"){
qDebug() << "DATA VALUE Board while #3" << reader.name();
while(reader.readNextStartElement()) {
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Boards #1" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Boards #2" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Boards #3" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Boards #4" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Boards #5" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Boards #6" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Boards #7" << reader.name();
reader.skipCurrentElement();
}
if(reader.readNextStartElement()) {
qDebug() << "DATA VALUE Boards #8" << reader.name();
reader.skipCurrentElement();
}
}
}
}
}
}
}
однако, мне не удалось полностью разобрать тег "board" ... было бы неплохо, если бы я мог получить некоторые подсказки, чтобы получить его. Кроме того, число тегов доски может варьироваться, и некоторые для eth_addresses, например, тег доски в приведенном выше примере 2 и 3.