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



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.