No it seems it is well formed XML, and it is strictly craeted by QXmlStreamWriter.
From your first post:
<?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
The hyphen '-' on line 2 is certainly not well formed XML: "Line 2 Column1 Content is not allowed in prolog". The other hyphens may or may not be correct.
Feed that to this simple reader:
#include <QCoreApplication>
#include <QFile>
#include <QXmlStreamReader>
#include <QDebug>
void readXmlFile() {
// This block structure straight from the Qt docs
QXmlStreamReader xml(&input);
while (!xml.atEnd()) {
xml.readNext();
// ... do processing
if (xml.isStartDocument()) {
qDebug() << "Start document";
}
else if (xml.isEndDocument()) {
qDebug() << "End document";
}
else if (xml.isStartElement()) {
qDebug() << "Start element:" << xml.name();
}
else if (xml.isEndElement()) {
qDebug() << "End element:" << xml.name();
}
else if (xml.isCharacters()) {
qDebug() << "Characters:" << xml.text();
}
else {
qDebug() << "Ignored something else";
}
}
if (xml.hasError()) {
// ... do error handling
qDebug() << "Error:" << xml.error() << xml.errorString();
}
}
else {
qDebug() << "Failed to open file";
}
}
int main(int argc, char **argv) {
readXmlFile();
return 0;
}
#include <QCoreApplication>
#include <QFile>
#include <QXmlStreamReader>
#include <QDebug>
void readXmlFile() {
QFile input("test.xml");
if (input.open(QIODevice::ReadOnly)) {
// This block structure straight from the Qt docs
QXmlStreamReader xml(&input);
while (!xml.atEnd()) {
xml.readNext();
// ... do processing
if (xml.isStartDocument()) {
qDebug() << "Start document";
}
else if (xml.isEndDocument()) {
qDebug() << "End document";
}
else if (xml.isStartElement()) {
qDebug() << "Start element:" << xml.name();
}
else if (xml.isEndElement()) {
qDebug() << "End element:" << xml.name();
}
else if (xml.isCharacters()) {
qDebug() << "Characters:" << xml.text();
}
else {
qDebug() << "Ignored something else";
}
}
if (xml.hasError()) {
// ... do error handling
qDebug() << "Error:" << xml.error() << xml.errorString();
}
}
else {
qDebug() << "Failed to open file";
}
}
int main(int argc, char **argv) {
QCoreApplication app(argc, argv);
readXmlFile();
return 0;
}
To copy to clipboard, switch view to plain text mode
and you get
Start document
Ignored something else
Error: 3 "Start tag expected."
Start document
Ignored something else
Error: 3 "Start tag expected."
To copy to clipboard, switch view to plain text mode
I am struggling to see what you are trying to achieve. If you just want to reproduce the XML file then just copy it.
Bookmarks