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. How to get the inner xml from a node using QXmlStreamReader?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
xmlqxmlstreamreadeinner xmlparsing
1 Posts 1 Posters 1.2k Views
  • 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.
  • A Offline
    A Offline
    ams_bob
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

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