'How to read second group of XML tags

Hello I have a problem with reading full XML file using QT. This is my main.cpp file


#include <QApplication>
#include <QFile>

int main(int argc, char *argv[])
{
    QXmlStreamReader xml;
    QFile file("testFile.xml");
    if(!file.open(QFile::ReadOnly | QFile::Text))
    {
        qDebug() << "error";
    }
    xml.setDevice(&file);
    while(!xml.atEnd())
    {
        if(xml.isStartElement())
        {
            QString name = xml.name().toString();
            if(name == "Osoba")
            {
                qDebug() << "Osoba===============================";
                for (int i = 0; i < xml.attributes().size(); i++)
                {
                    qDebug() << xml.attributes().at(i).name() << xml.attributes().at(i).value();
                }
            }
            if (name == "Imie" || name == "Nazwisko" || name == "Adres" || name == "Telefon" || name == "Www" || name == "Email") {
                for (int i = 0; i < xml.attributes().size(); i++)
                {
                    qDebug() << xml.attributes().at(i).name() << xml.attributes().at(i).value();
                }
                QString text = xml.readElementText();
                qDebug() << name << text;
            }
        }
        if(xml.isEndElement())
        {
            QString name = xml.name().toString();
            if(name == "Osoba")
            {
                qDebug() << "Osoba================================";
            }
        }
        xml.readNext();

    }
    if(xml.hasError())
    {
        qDebug() << "Error";
    }
    QApplication a(argc, argv);
    MainWindow w;
    //w.show();
    return a.exec();
}

and I can successfully read content of <Osoby> ... </Osoby>, but I don't know how to read in the same script content of <Grupy> ... </Grupy>. I would be very thankful if you could provide me any tips or piece of code how to achive this.

This is the file I'm using:

<?xml version="1.0" encoding="utf-8"?>
    <Osoby>
        <Osoba id="1">
            <Imie plec="M">Sample Name</Imie>
            <Nazwisko>Sample Lastname</Nazwisko>
            <Adres>Sample address</Adres>
            <Telefon>123123123</Telefon>
            <Www>sample www</Www>
            <Email>sample Email</Email>
        </Osoba>
        <Osoba id="2">
            <Imie plec="K">Sample Name 2</Imie>
            <Nazwisko>Sample Lastname 2</Nazwisko>
            <Adres>Sample address 2</Adres>
            <Telefon>313321321</Telefon>
            <Www>sample www 2</Www>
            <Email>sample email 2</Email>
        </Osoba>
    </Osoby>
    <Grupy>
        <Praca>
            <ID>1</ID>
        </Praca>
    </Grupy>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source