From 10:00 CET Friday 22nd November we will adjust how the server works to deal with some recently reported problems. Therefore there may be a load problem, if you experience more problems than usual trying to access the forum then please PM AndyS or any of the moderators so they can inform me.


How to get the inner xml from a node using QXmlStreamReader?



  • Hi, I'm trying to efficiently parsing a large xml file. The parser shall be split in a generic part which parses the main structure of the xml-file (first and second level nodes) and in different custom parts which continue parsing details from 3rd level nodes.

    The whole node at level 3 should be given to a custom parser (as QString).

    My approach was to use the QXmlStreamReader because the documentation sais that this is the fastest and most efficient way to parse an xml-file without loading the whole content in memory.
    Unfortunately i didn't find a function that allows to collect the inner text of a node.
    I don't want to pass the reference of the StreamReader to the the custom parsers because they may read too much if they are buggy. The outer/generic parser at level 1 and 2 should be able to control the content given to the custom parsers.

    I'd be glad if somebody could help me with this issue. Maybe i am on the wrong way...

    Here a sample xml which should be parsed:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE LogData>
    <LogData>
    <LogEntry>
    <ReadData>
    <Timestamp year="2015" month="11 day="13" time="12:19:22.037"/>
    <Address>0x22</Address>
    <Value>0x42</Value>
    </ReadData>
    </LogEntry>
    <LogEntry>
    <ReadData>
    <Timestamp year="2015" month="11 day="13" time="12:19:22.192"/>
    <Address>0x23</Address>
    <Value>0x55</Value>
    </ReadData>
    </LogEntry>
    <LogEntry>
    <WriteData>
    <Timestamp year="2015" month="11 day="13" time="12:19:23.744"/>
    <Address>0x20</Address>
    <Value>0x13</Value>
    <Mask>0x3F</Mask>
    <Policy>0</Policy>
    </WriteData>
    </LogEntry>
    <LogEntry>
    <WriteData>
    <Timestamp year="2015" month="11 day="13" time="12:19:23.835"/>
    <Address>0x21</Address>
    <Value>0x02</Value>
    <Mask>0x3F</Mask>
    <Policy>1</Policy>
    </WriteData>
    </LogEntry>
    <LogEntry>
    <SetConfig>
    <Classes>
    <Class Name="Msc::Trigger"/>
    <Class Name="Msc::Logger"/>
    <Class Name="Msc::Parser"/>
    </Classes>
    </SetConfig>
    </LogEntry>
    </LogData>

    The generic parser should only parse <LogData> and <LogEntry> tags. Everything which is within ONE <LogEntry> should be given to a custom parser depending on the inner tags name. But QXmlStreamReader does not seem to provide a function which gives the inner xml of a node :-/

    Thanks a lot for answers.

    BR