Problem while retrieve data from XML



  • Currently the XmlListModel is the only element available for reading XML data. This is useful for creating a model from XML data, but does not work well for nested XML list data (since this requires using nested XmlListModels) and also doesn't fit the task if the application only requires some piece of data from the XML, and not a complete model.

    so i have a XML File and i want to view it in sequences when the user click the first sub_category just show the item for the first sub_category not for all etc.... for all sub_category ?

    How to solve this problem using QML ?



  • You can create your custom model in C++ (where you will do xml parsing by hand) and provide it to your listview.



  • Hi,

    You can also use "XMLHttpRequest":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeglobalobject.html#xmlhttprequest to work with XML data in QML.

    Regards,
    Michael



  • i need to make it using QML

    what i need exactly is
    when i have a XML file like this :
    @
    <real_estates>

    • <sub_category name="eeeee">
    • <class name="gfgfgf">
    • <purpose name="bgbgbg">
      <area name="ererr" />
      <area name="erere" />
      <area name="werwe" />
      <area name="erfrfd" />
      <area name="vfvf" />
      </purpose>
    • <purpose name="fgfgf">
      <area name="frere" />
      <area name="www" />
      <area name="eewew" />
      <area name="yty" />
      <area name="plpl" />
      <area name="wewe" />
      <area name="lklklk" />
      </purpose>
      <purpose name="wewe">
    • <area name="wewe">
    • <ad>
      <text>ت:5490446-079</text>
      </ad>
    • <ad>
      <text>: 5688989-079</text>
      </ad>
    • <ad>
      <text>: 9649454-079</text>
      </ad>
    • <ad>
      <text>AAAAAAAA</text>
      </ad>
      </area>
      <area name="bbb" />
      <area name="cccc" />
      <area name="hhhh" />
      <area name="lllllll" />
      <area name="yyyy">
      <text>eeeeeee</text>
      </ad>
    • <ad>
      <text>lklkklk</text>
      </ad>
    • <ad>
      <text>8571666-078</text>
      </ad>
      <text> - ت:5922181-079</text>
      </ad>
      </area>
      <area name="lklklk" />
      </purpose>
      <sub_category name="oooooo">
    • <class name="wewe">
    • <purpose name="qwwwe">
      <area name="wwww" />
      <area name="fffff" />
      <area name="mmmmm" />
      </purpose>
      </class>
      </sub_category>
      </real_estates>
      @

    So what i want take just some of it not all of it , when i choose the first cat just see the first not all of data

    [edit: xml highlighted / Denis Kormalev]



  • Please don't forget to highlight your code blocks with @ tags.
    You can do it with mbrasser's suggestion, but I don't think you should stick to QML. in C++-way it will be much more flexible and with better performance (especially if you will have huge xmls).


Log in to reply
 

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