I am working with xml files, using the QT Liberia. The problem that presents itself to me is as follows: I do not know how to read the attributes of xml tags using QXmlStreamReader.
For example I have the following file:
<?xml version="1.0" encoding="UTF-8"?>
<wells>
<number-wells value="3"/>
<wells-info>
<row well-number="1" nodes="2" well-name="0.00000" Krg="">
<row well-number="1" nodes="2" well-name="0.00000" Krg="">
<row well-number="1" nodes="2" well-name="0.00000" Krg="">
</wells-info>
<wells-direction>
<row well-number="1" i="5" j="5" k="1" idir="1">
<row well-number="2" i="5" j="5" k="1" idir="1">
<row well-number="3" i="5" j="5" k="1" idir="1">
</wells-direction>
</wells>
According to what I was reading on some sides, I suggested the following:
xml.setDevice(&archivo);
QXmlStreamAttributes atributos;
while(!xml.atEnd()){
qDebug() << xml.readNext();
if(xml.isStartElement()){
QString etiqueta = xml.name().toString();
if(etiqueta == "number-wells"){
atributos = xml.attributes();
foreach(const QXmlStreamAttribute &att, atributos) {
qDebug() << "atributo" << att.name() << att.value();
}
}
if(etiqueta == "wells-info"){
qDebug() << "etiqueta: " << etiqueta;
while(xml.readNextStartElement()) {
if(etiqueta == "row"){
qDebug() << "etiqueta: " << etiqueta;
atributos = xml.attributes();
foreach(const QXmlStreamAttribute &att, atributos) {
qDebug() << "atributo" << att.name() << att.value();
}
}
else xml.skipCurrentElement();
}
}
}
xml.readNext();
} //end WHILE*/
if(xml.hasError()){
QMessageBox::critical(this,"Error","No se ha podido leer el archivo "+fileNameWell);
}
You're just showing me the following:
2
6
5
4
tag: "wells-info"
QXcbConnection: XCB error: 3 (BadWindow), sequence: 986, resource id: 17307926, major code: 40 (TranslateCoords), minor code: 0
What can it be?