Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Thumbnails in rss
Forum Updated to NodeBB v4.3 + New Features

Thumbnails in rss

Scheduled Pinned Locked Moved Mobile and Embedded
13 Posts 3 Posters 5.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    awasay
    wrote on last edited by
    #1

    Hi,

    I am trying to parse an rss xml. I am new to parsing and new to Qt, so bear with me.

    In my rss feed i have a tag like this

    @
    <media:thumbnail url="http://../*/****/GetImage.aspx?id=1555B71D7BEA3AAB" />
    @

    My question is how do i parse it. I mean against what tag. Secondly when I do parse it what do I get. Do i just get the url? Do i get the Image? Thirdly if I want to display this thumbnail, how do i do that. Is there any way to display an image direct from a url in Qt? specially inside a QTreeWidget. Finally, how do i download the image and resize it to be displayed if i cannot display it directly from the url?

    I know these are a lot of questions but I am new and kind of feel like I am running around in circles, chasing my tail. Your patience in answering all of these will be much appreciated.

    Abdul

    [EDIT: code formatting for XML snippet, Volker]

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      rss is an XML format, so I would suggest you use the XML functionality in Qt to do the parsing for you instead. That will be way less error-phrone and much easier. Might I suggest QXmlStreamReader for the job?

      What you have in the tag you display is a URL. That is: a web address. You will need to use a class like QNetworkAccessManager to retreive the contents. There is a way to do it directly, but only in QML. It would be nice if the functionality to load images directly from a URL was somehow exposed on the C++ side as well, but it is not at this moment.

      Once you have the image inside a QImage, you can use that class to do the resizing for you. To put it in a QTreeWidget, you simply set the QImage as data on the appropriate item using the Qt::DecorationRole.

      You are right that you're asking a lot of questions at once. Perhaps you should first try your hand with some of the Qt tutorials. I have given you some pointers, but the idea is not that people here will write the code for you. You're expected to do your own research too.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        awasay
        wrote on last edited by
        #3

        Thank you for all the pointers. I have been going through the tutorials and everything and they are wonderful.

        But i think I didn't make my problem clear. I am using the parser in Qt. My problem is that I have not yet found a way to parse the tag that i have given above.

        Let me make it clear with an example.

        <name> blah blah blah </name>

        this line is easily handled by my parser but

        <media:thumbnail url = "....." />

        what tag do i search this against? My parser doesn't even read it. The last tag it reads is "guid" then it moves on to the next item. I should mention that the rss feed i am trying to parse is a media rss.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          [quote author="awasay" date="1297937083"]
          <media:thumbnail url = "....." />

          what tag do i search this against? My parser doesn't even read it. The last tag it reads is "guid" then it moves on to the next item. I should mention that the rss feed i am trying to parse is a media rss. [/quote]

          This is a tag with namespace prepended. You will have to consider this. The local tag name without namespace should be "thumbnail".

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            awasay
            wrote on last edited by
            #5

            Thank you. i can now get into the thumbnail tag. A new problem has arisen though. My parser is not dealing with the empty spaces. How do i make it either skip the empty space or get the line with the empty space.

            In my research so far, all skip functions skip the whole element.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              Whatever "empty spaces" are...

              Throw away your parser and start from scratch using "QDomDocument":http://doc.qt.nokia.com/4.7/qdomdocument.html or "QXmlStreamReader":http://doc.qt.nokia.com/4.7/qxmlstreamreader.html

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • A Offline
                A Offline
                awasay
                wrote on last edited by
                #7

                Once again i thank you for your patience. I am using the QXmlStreamReader. In fact most of my code is copied from the help section. The problem is that it is not dealing with a tag of the type mentioned above. "empty space" is where there is nothing.
                when i find the tag "thumbnail", i call the function

                myString = xml.text().toString();

                when I display myString through QDebug, it is shown empty. my theory is that it is being displayed empty because the parser is not dealing with the tag properly.

                P.S. I am able to get the simple tags displayed properly.

                Abdul

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  You should learn the difference between tag, tag content and attribute. I'd suggest an introduction or tutorial to XML to make yourself comfortable with the XML concepts.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    awasay
                    wrote on last edited by
                    #9

                    thank you once again. like i mentioned in the beginning, i am new to all of this. today has been a steep learning curve helped by all of you. incidentally, i just figured out (before reading your post) that the text function would return empty, i need to somehow access the attributes of "media". now i am off to find how to access attributes. if anyone of you is feeling in a giving mood then feel free to point me in the right direction.

                    P.S. I know handing stuff out on a plate is frowned upon in the forums and I agree with it most of the times but i feel that sometimes quick answers do lead to quick learning as well.

                    My two cents,
                    Abdul

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #10

                      "RTFM!":http://en.wikipedia.org/wiki/RTFM

                      Is it really so hard to go to http://doc.qt.nokia.com/4.7/qxmlstreamreader.html, hit Ctrl-F, enter "attribute" click some times on "search more" and eventually find yourself at the right place.

                      You are just stinking lazy if you expect others to do the actual work for you! You are very welcome to ask questions if you have a real problem and a real question. But everyone is upset if you just steal their times when on the answer is crystal clear in the docs!

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        awasay
                        wrote on last edited by
                        #11

                        i do not wish to make you angry, i apologize for my behavior. I did not say that I was not going to look. In fact I am reading the docs that you have mentioned at the moment(without using your provided links). My point was that "sometimes", if you have gone through a similar problem yourself, you can give the solution.

                        I apologize once again.

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          goetz
                          wrote on last edited by
                          #12

                          This is true, but only for "serious" problems, not for questions that are easily answered in the API docs. Some work an research should always be done, before asking in a forum.

                          So, have fun reading the Qt docs (the are really good!) :-)

                          http://www.catb.org/~esr/faqs/smart-questions.html

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            awasay
                            wrote on last edited by
                            #13

                            Hey thanx once again for bearing with me. I have figured out some part of the attributes problem. Its still not as clear as I would like it to be but at least its working. I am sure the clarity will come with time.

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved