​Hi Gianluca,

depending on the full XML you can query for the description tag and than
query for the first img tag with "[1]", something like this:


         XmlListModel {

            id: model


            query: "(/path/to/description/img)[1]"

            XmlRole { name: "img"; query: "@src/string()" }

        }

​

Here I defined a role for the "src" attribute as a string.
Hope that helps.

Cheers,


---
Federico Buti

On 3 June 2015 at 11:26, Gian Maxera <gmax...@gmail.com> wrote:

> Hello,
> I have an rss feed coming from Tumblr blog page.
> The xml of the feed has into description a lot of html content that I want
> to remove and keep only the first image I found.
> For example, this is one of the content into description tag:
>
> <description>&lt;img 
> src="http://33.media.tumblr.com/bd4312958b742a21221e87c0a96d52c1/tumblr_np213siZRu1tbs1mwo1_500.gif"/&gt;&lt;br/&gt;
>  &lt;br/&gt;&lt;img 
> src="http://33.media.tumblr.com/6f1ca4ab1ef3d2504b2da48f2616df6e/tumblr_np213siZRu1tbs1mwo2_400.gif"/&gt;&lt;br/&gt;
>  Paris Marriott Champs Elysees&lt;br/&gt;&lt;br/&gt; &lt;img 
> src="http://36.media.tumblr.com/0f4726dd2f19c8d4a042f72786987573/tumblr_np213siZRu1tbs1mwo3_500.jpg"/&gt;&lt;br/&gt;
>  &lt;br/&gt;&lt;h2&gt;&lt;b&gt;Marriott Hotels in France Celebrate Earth Hour 
> 2015&lt;/b&gt;&lt;/h2&gt;&lt;p&gt;See what happened during Earth Hour 
> celebrations at Marriott hotels in France.&lt;/p&gt;</description>
>
>
> What I would like is to have a XPath function that return me only the
> first image url:
>
> http://33.media.tumblr.com/bd4312958b742a21221e87c0a96d52c1/tumblr_np213siZRu1tbs1mwo1_500.gif
>
>
> How can I do that ?
>
> Thanks,
> Gianluca.
>
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to