Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Problem using XmlListModel query to parsing rss xml



  • here is the rss xml :
    @
    -<rss version="2.0">
    -<channel>
    -<item>
    -<description>
    <img src="">or, The Ship Wreck; also A Voyage to Norway; and The Fisherman's Cottage. </p><p>Author: Agnes Strickland </p>
    <p>Language: English </p><p>Published: 1851 </p>
    -</description>
    -</item>
    -</channel>
    -</rss>
    @
    now I want to get the content of <p>

    but in the XmlListModel{},the query role is "/rss/channel/item",I can not using /rss/channel/item/description to get <p>

    here is my code :
    @
    import QtQuick 1.0

    XmlListModel{
    id:feedModel
    property string currentFeed: "http://www.manybooks.net/rss/ADV.xml"

    source: currentFeed
    query:  "/rss/channel/item"
    XmlRole { name: "title"; query: "title/string()" }
    XmlRole { name: "pubDate"; query: "pubDate/string()" }
    XmlRole { name: "cover"; query: "description/string()" }
    

    }
    @
    How can I get <p> in <description>
    Thank you very much!

    Plaese forgive my poor English!

    thanks again!



  • Hi,

    Could you please double check your XML file - it contains some mistyped characters as I see it. Also there is opening <p> which is missing...so please clean it first a bit and then specifiy exactly what do you expect to grab from the xml as pass it over to the role.


Log in to reply