Results 1 to 3 of 3

Thread: Qt 5.3 QXMLStreamReader on non-XML file

  1. #1
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    77
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Qt 5.3 QXMLStreamReader on non-XML file

    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:

    <F:L:T>D

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

    <NAME:0>

    <NAME:3>Ray

    An optional data type indicator may be added:

    <NAME:3:S>Ray

    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?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt 5.3 QXMLStreamReader on non-XML file

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt 5.3 QXMLStreamReader on non-XML file

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Reading and rereading a file with QXmlStreamReader
    By TheRonin in forum Qt Programming
    Replies: 14
    Last Post: 30th April 2015, 14:04
  2. How to read the xml file using QXmlStreamReader
    By mythili in forum Qt Programming
    Replies: 1
    Last Post: 7th June 2013, 16:17
  3. Replies: 1
    Last Post: 1st August 2012, 09:56
  4. QXmlStreamReader
    By sophister in forum Qt Programming
    Replies: 6
    Last Post: 24th August 2011, 17:31
  5. Replies: 3
    Last Post: 3rd April 2010, 20:35

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.