[Qt-interest] qxmlstreamreader vs multiple classes

Jiri Horky jiri.horky at gmail.com
Thu Nov 26 23:03:44 CET 2009


Hi,

I have a raw idea how to do this, but I would like to ask if there is a
common practice. I want to parse some xml file using multiple instances
(of different clasess) of QXmlStreamReader, read below:

I have working code that parses current version of given xml file. This
xml file (and whole application as well) is going to be expanded, in the
way that it will contain multiple of previous root elements covered in
new root element, ie:

it was
<panel id="1">
....
</panel>

now it will be:
<panels>
   <panel id="1">
    ...
    </panel>
   <panel id="2">
    ...
    </panel>
<panels>

What I want to do is to reuse existing class parsing<panel> element and
introduce new class that will parse "whole document" but which will call
appropriate reader of given instance of panel. (There will PanelManager
class that contains more Panel classes).

The question is, how to achieve that? I haven't found any example of
such scheme. My idea is to call panelXX->addData(copy of right part of
xml file) , panelXX->parse() and then skipPanelElement() every time I
find <panel> element. But the copying and double reading seems quite
inefficient and nasty to me....
I bet there is a better solution, could you please guide me?

Thanks.

Regards
Jiri Horky





More information about the Qt-interest-old mailing list