I have an xml-document where a node with the same name is stored in two different ways:
Either
<element>A Text</element>
or
<element>
<name> A Text </name>
<value> 12 </value>
</element>
I’m parsing that document with QXMLStreamReader and I’m searching for a way how to detect whether it is only a Text or child nodes.
I tried allready
QXmlStreamReader& xml;
QString name;
xml.readNext();
QStringView test = xml.text();
if (text.isNull())
{
//Go into child nodes
while (xml.readNextStartElement())
{
if (xml.name() == "name")
name = xml.readElementText()
else
xml.skipCurrentElement();
}
}
else
{
name = text.toString();
}
But that does not detect the childs in case of text.isNull()
It is currently not possible to change the parser, because this is a quite old and big one, and it also not possible to change the structure of the XML-File
ThS is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.