View Full Version : Qt 5.3 QXMLStreamReader on non-XML file

26th May 2014, 20:27
I am attempting to create a non-XML parser for a file that is almost XML but not. By that I mean the data is identified by:


The data length L is ASCII text, and may be of any non-negative value including 0:



An optional data type indicator may be added:


So far I have constructed a schema file that has all the elements defined as needed in a file I called adif_spec.xsd.

My code creates a sub-classed reader to read the data file using the schema and create a XML output file.

My problem is all my attempts to read in the raw data and have the reader convert the data in the above format to XML have not been productive. I have no idea where to go from here.

The docs are not terribly specific and they assume a thorough knowledge of the process of applying the Qt XML libraries to this task.
Can anyone point me in the right direction?

26th May 2014, 20:47
Just because your format sort of looks like XML but really isn't XML, what makes you think an XML reader will read it?

XML is a strictly-defined format. Any XML file MUST start with the <?xml version=... ?> tag, and MUST have matched pairs of <whatever> and </whatever> elements inside it. It MUST have a "root element" and all other elements MUST be nested inside the root element.

The syntax for <> elements is defined by the XML standard, and yours don't obey the rules. About the only thing your file has in common with XML is the use of angle brackets.

Forget trying to get the Qt XML libraries (or any other XML parser) to work on parsing this. It isn't XML, and any parser will simply reject it as invalid XML. Either convert your file to proper XML, or write your own custom parser.

27th May 2014, 22:26
The grammar of your format is pretty easy, there is a number of parser generators out there that you can use to generate a parser for your format or even write a parser by yourself (e.g. using regular expressions). Just stay away from XML parsers, your format is not XML.