Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. XML parsing problem (error triggered by consumer)
Forum Updated to NodeBB v4.3 + New Features

XML parsing problem (error triggered by consumer)

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mushroom
    wrote on 27 Oct 2011, 15:31 last edited by
    #1

    Hello,

    I'm trying to parse XML data that I recieve over a bluetooth socket by passing the QByteArray to the XML handler.
    The process works and the full data is transmitted but parsing fails on line 2, column 6 of the XML file even though the XML is completely legal (checked with W3Schools validator).

    Here's the function that takes and parses the XML:
    @bool SaxHandler::readFile(const QByteArray &data)
    {

    QXmlInputSource source;
    source.setData(data);
    QXmlSimpleReader xmlReader;
    
    qDebug() << source.data();
    
    xmlReader.setContentHandler(this);
    xmlReader.setErrorHandler(this);
    
    return xmlReader.parse(source);
    

    }@

    Here's the console output, also showing the contents of the XML file (The error details come from the error handler):
    @"<?xml version="1.0"?>
    <data>
    <wind_direction>50</wind_direction>
    <wind_speed>0</wind_speed>
    <temperature>12</temperature>
    <humidity>95</humidity>
    <rain>89</rain>
    </data>"

    fatalError: "error triggered by consumer"
    lineNumber: 2
    columnNumber: 6@

    The error seems to be between the 'a' and the '>', but I see nothing wrong and the XML is legal.
    What could possibly be wrong?

    Thanks in advance!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mushroom
      wrote on 27 Oct 2011, 16:06 last edited by
      #2

      Looks like the problem is in my content handler, if i comment it out the parsing succeeds.
      @//xmlReader.setContentHandler(this)@

      I guess it was stupid of me to leave implementing it for later, all i had there was a qDebug() which i omitted from the above posts output. I just wanted to test if everyting works before i continue working, time to implement the handler then :)

      Thanks anyway!

      1 Reply Last reply
      0

      1/2

      27 Oct 2011, 15:31

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved