Filter Rss feed application items



  • <row>
    <field name="esid">539661</field>
    <field name="esname">sdsdsds</field>
    <field name="text">
    tyudsgfdsf
    </field>
    <field name="esinfo" xsi:nil="true"/>
    <field name="esbegin">2000-11-22</field>
    <field name="date">2012-03-31</field>
    <field name="time">19:00:00</field>

    <field name="venue">Colombo</field>
    </row>

    This is my RSS feed XML contains. I have created RSS feed application similar to demo Rssfeed example in QTCreator. Now I want to display only the items relevant to a date. this is RssFeeds.qml file. when user clicks on Today items belong to the current date should be listed in the area.

    ListModel {
    id: rssFeeds

    ListElement { name: "Today"; feed: "url" }
    ListElement { name: "This week"; feed: "url" }   
    

    }

    if anyone know how to implement this. please help me.



  • Hi,
    it is so simple using XmlListModel.

    I have delete xsi:nil="true" because it was conflicted. Maybe you could do an replace of string and delete it.

    The solution would be like this:
    @
    XmlListModel{
    id:model
    query:"/row"
    XmlRole{name:"date";query:"field[attribute::name='date']/string()"}
    xml:"<row>
    <field name='esid'>539661</field>
    <field name='esname'>sdsdsds</field>
    <field name='text'>tyudsgfdsf</field>
    <field name='esinfo'/>
    <field name='esbegin'>2000-11-22</field>
    <field name='date'>2012-03-31</field>
    <field name='time'>19:00:00</field>
    <field name='venue'>Colombo</field>
    </row>"
    onStatusChanged: {
    if(status==XmlListModel.Ready){
    for(var i =0;i<model.count;i++){
    console.log(model.get(i).date)
    }
    }
    }
    }
    @
    thanks to gentooxativa for helping :).

    Best Regards.


Log in to reply
 

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