XmlListModel queries



  • I have such xml in source of XmlListModel

    @<items>
    <playlist_name>PLAYLIST MEGA NAME</playlist_name>
    <channel>
    <title>title_1</title>
    <logo>logo_1.jpg/logo>
    <description>desctiption_1</description>
    <playlist_url>playlist_1.htm</playlist_url>
    </channel>
    <channel>
    <title>title_n</title>
    <logo>logo_n.jpg/logo>
    <description>desctiption_n</description>
    <playlist_url>playlist_n.htm</playlist_url>
    ....
    @

    and I have qml like

    @XmlListModel {
    source: "http://example.com/playlists.xml"
    query: "/items/channel"
    XmlRole { name: "logo"; query: "logo/string()" }
    XmlRole { name: "title"; query: "title/string()" }
    XmlRole { name: "description"; query: "description/string()" }
    XmlRole { name: "playlist_url"; query: "playlist_url/string()" }
    XmlRole { name: "stream_url"; query: "stream_url/string()" }
    }@

    and I have 2 troubles:

    how to get access to /items/playlist_name (single-instance-tag) ?

    I tried

    XmlRole { name: "playlist_name"; query: "/items/playlist_name/string()" }

    but this construction failed :-(

    And I have other xml-srtuct like first but instead of /items/content/playlist_url field named /items/content/stream_url

    It is possible to describe it with one XmlListModel?
    How to detect type of model by presence playlist_url or stream_url?

    Thx.


Log in to reply
 

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