Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkAccessManger get returns invalid XML as response for few URLs
Qt 6.11 is out! See what's new in the release blog

QNetworkAccessManger get returns invalid XML as response for few URLs

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • R Offline
    R Offline
    Revathy
    wrote on last edited by
    #1

    I am using qt - QNetworkAccessManager to read contents from a News portal as shown below

    QNetworkReply *reply;
    QNetworkAccessManager *network = new QNetworkAccessManager;
    network->setNetworkAccessible(QNetworkAccessManager::Accessible);

    reply = network->get(QNetworkRequest(QUrl("http://news.yahoo.com/rss/sports")));

    //Another URL to test "http://news.yahoo.com/rss/baseball"

    And the I am trying to read the response as shown below

    QString response = reply->readAll();

    For few URLs we get proper XML as reply but for few others the XMLs are not proper.

    The problem here is - Same URLs for which the XMLs were not well formed works fine everytime showing proper output on desktop browser.

    We are able to reproduce this issue with QtSDK/demos/4.7/declarative/rssnews example too if we try to hardcode the above mentioned URL there.

    Example for Invalid XML obtained looks something like below : (Proper XML should have title, description tags)

    <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><html lang="en" xml:lang="en"><head><title>Sports News Headlines - Yahoo! News</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><style type="text/css">body{color:#353535;background:#ffffff;font-family:Sans-serif}a{color:#006ec2;text-decoration:none}a.z, a.y, a.x, a.w, a.v, .u a{text-decoration:none}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6{padding:0;margin:0}img{border:0}hr{display:none;visibility:hidden;width:0}#page{background:
    .............................
    .......................................
    ....................................................
    cir0Pb17r9HJLHyL2H6qC_rG"><span>Help</span></a></div><div class="o p ">© 2013 Yahoo! Inc. All rights reserved</div></div></div></div></div><img alt="" src="http://us.bc.yahoo.com/b?P=92jfVTc2LjFqpOI6f__DZQGKMTI1LlFSw2X_m5fY&T=1ehh1jvjf/X=1364378469/E=954001251/R=mi/K=5/V=10.1/W=C/Y=YAHOO/F=1168823538/H=YmVzdC13b2VpZD0iMjI5NTQyMCIgY2Fycmllcj0iSU4tVU5LTk9XTiIgY29udGVudD0ibW9iaWxlX25ld3MiIGR2Y19jbHM9IjQiIHBuPSJ5YWhvb19tb2JpbGVfdXNfd2ViIiBycz0icHJpOnlhaG9vX21vYmlsZV91c193ZWI7c2VjOnlhaG9vO2NycjpJTi1VTktOT1dOOyIgc2VydmVJZD0iOTJqZlZUYzJMakZxcE9JNmZfX0RaUUdLTVRJMUxsRlN3MlhfbTVmWSIgc2l0ZUlkPSI0OTAyNTUxIiB0U3RtcD0iMTM2NDM3ODQ2OTk3MTg3MCIg/Q=-1/I=1/S=1/J=36F70D4C&U=12cle5obm/N=TWHUE2KJiVo-/C=-1/D=WFB2/B=-1/V=0"/> <!-- SpaceID:954001251 --></body></html>
    <!-- webgw51.mobile.sp1.yahoo.com uncompressed/chunked Wed Mar 27 10:01:09 GMT 2013 -->
    <!-- fe621.global.media.sg3.yahoo.com uncompressed/chunked Wed Mar 27 10:01:09 UTC 2013 -->

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NicuPopescu
      wrote on last edited by
      #2

      Hi,

      you should read data from the reply after finished() signal is emitted ... have you done so?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Revathy
        wrote on last edited by
        #3

        Yes I am reading data only after finished() signal is emitted.

        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