I have such xml-file contents written with Qxmlstreamwriter:
<?xml version="1.0" encoding="UTF-8" ?>
- <FILESYSTEM>
- <FILE>
<NAME>autoc.JPG</NAME>
<SIZE>19197</SIZE>
<PATH>c:/c</PATH>
</FILE>
- <FILE>
<NAME>copy autoc.JPG</NAME>
<SIZE>19197</SIZE>
<PATH>c:/c</PATH>
</FILE>
- <FILE>
<NAME>copy copy autoc.JPG</NAME>
<SIZE>19197</SIZE>
<PATH>c:/c</PATH>
</FILE>
- <FILE>
<NAME>copy copy copy autoc.JPG</NAME>
<SIZE>19197</SIZE>
<PATH>c:/c</PATH>
</FILE>
</FILESYSTEM>
<?xml version="1.0" encoding="UTF-8" ?>
- <FILESYSTEM>
- <FILE>
<NAME>autoc.JPG</NAME>
<SIZE>19197</SIZE>
<PATH>c:/c</PATH>
</FILE>
- <FILE>
<NAME>copy autoc.JPG</NAME>
<SIZE>19197</SIZE>
<PATH>c:/c</PATH>
</FILE>
- <FILE>
<NAME>copy copy autoc.JPG</NAME>
<SIZE>19197</SIZE>
<PATH>c:/c</PATH>
</FILE>
- <FILE>
<NAME>copy copy copy autoc.JPG</NAME>
<SIZE>19197</SIZE>
<PATH>c:/c</PATH>
</FILE>
</FILESYSTEM>
To copy to clipboard, switch view to plain text mode
I try to extract the same view and order of this xml to console (but then in GUI TextEdit) with such
simple function:
void Mainclas::readxmlfile()
{
QXmlStreamReader Rxml;
Rxml.setDevice(&file);
Rxml.readNext();
while(!Rxml.atEnd())
{
if(Rxml.isStartDocument()) {
qDebug()<<"<?xml"<<Rxml.documentEncoding ().toString()<<" "<<Rxml.documentVersion().toString()<<"?>";
Rxml.readNext();
}
if(Rxml.isStartElement()) {
qDebug()<<"<"+Rxml.name().toString()<<">";
Rxml.readNext();
}
if(Rxml.isEndElement()) {
qDebug()<<"</"+Rxml.name().toString()<<">";
Rxml.readNext();
}
if(Rxml.isCharacters ()) {
if(Rxml.text()=="") Rxml.readNext();
qDebug()<<Rxml.text();
Rxml.readNext();
}
}
}
void Mainclas::readxmlfile()
{
QXmlStreamReader Rxml;
QString filename="D:\\file00.xml";
QFile file(filename);
file.open(QIODevice::ReadOnly);
Rxml.setDevice(&file);
Rxml.readNext();
while(!Rxml.atEnd())
{
if(Rxml.isStartDocument()) {
qDebug()<<"<?xml"<<Rxml.documentEncoding ().toString()<<" "<<Rxml.documentVersion().toString()<<"?>";
Rxml.readNext();
}
if(Rxml.isStartElement()) {
qDebug()<<"<"+Rxml.name().toString()<<">";
Rxml.readNext();
}
if(Rxml.isEndElement()) {
qDebug()<<"</"+Rxml.name().toString()<<">";
Rxml.readNext();
}
if(Rxml.isCharacters ()) {
if(Rxml.text()=="") Rxml.readNext();
qDebug()<<Rxml.text();
Rxml.readNext();
}
}
}
To copy to clipboard, switch view to plain text mode
But I got
"<FILESYSTEM" >
"
"
<FILE>
"<FILESYSTEM" >
"
"
<FILE>
To copy to clipboard, switch view to plain text mode
Here is console printscreen - readxml.jpg
Why it happened? how to resolve it?
Should it be some error due to absent of such eroor-handler?
Bookmarks