QFile file("example.xml"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Failed to open file for reading."; return; } QXmlStreamReader xml(&file); while (!xml.atEnd()) { QXmlStreamReader::TokenType token = xml.readNext(); if (token == QXmlStreamReader::StartElement) { qDebug() << "Element: " << xml.name(); } } file.close();This code opens an XML file called "example.xml", creates a QXmlStreamReader instance to read it, and uses a while loop to read through each token of the file. For each start element token, the element name is printed to the console. QXmlStreamReader is part of the Qt Core library, which is included in the Qt package.