Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-12953

Element for creating an object from XML data

    XMLWordPrintable

Details

    Description

      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.

      What would be useful is a XmlObject element or something similar that is like XmlListModel, but isn't a model. Instead, it creates a single object with properties created from the XML data.

      E.g.

      XmlObject {
          id: xmlObj
          xml: xmlDataString
      }
      
      var name = xmlObj.root.slideshow[0].name
      

      Can also set query on it like XmlListModel:

      XmlObject {
          id: xmlObj
          xml: xmlDataString
          query: "root/slideshow[0]"
      }
      
      var name = xmlObj.name
      

      Could be used in combination with XmlListModel to read more complex models e.g.

      XmlListModel {
            id: model
            source: "feed.xml"
            query: "/root/slideshow"
            
            XmlRole {
                name: "slides"; query: "slide"
                objectDefinition: XmlObject {
                    xml: rawXml
                    XmlProperty { query: "blah"; name: "propertyName"}
                }
            }
      }
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              bealam Bea Lam (closed Nokia identity) (Inactive)
              Votes:
              9 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes