Answer the question
In order to leave comments, you need to log in
How to parse Xml data received via serial in QT?
Through the Emulator I send this line to the com port
<FileIndex>
<Name>lol.xml</Name>
<Size>0</Size>
<Path>E:/test/build-untitled-Desktop_Qt_5_4_1_MinGW_32bit-Release/lol.xml</Path>
<Created>Сб мар 14 21:55:37 2015</Created>
<Name>Makefile</Name>
<Size>20399</Size>
<Path>E:/test/build-untitled-Desktop_Qt_5_4_1_MinGW_32bit-Release/Makefile</Path>
<Created>Чт мар 12 19:00:45 2015</Created>
</FileIndex>
xmlReader=new QXmlStreamReader();
QByteArray byte;
byte=serialPort->readAll();
QString str=QString(byte);
//добавляем в xml
xmlReader->addData(str);
while(!xmlReader->atEnd())
{
QXmlStreamReader::TokenType token = xmlReader->readNext();
if(token == QXmlStreamReader::StartElement) {
if(xmlReader->name() == "name") {
xmlReader->readNext();
qDebug()<<xmlReader->text().toString();
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question