Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2013

    QNetworkAccessManger get returns invalid XML as response for few URLs

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

    QNetworkReply *reply;
    QNetworkAccessManager *network = new QNetworkAccessManager;

    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:

    <?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 xmlns="http://www.w3.org/1999/xhtml" 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&amp;T=1ehh1jvjf%2fX%3d1364378469%2fE%3d954001251%2fR%3dmi%2fK%3d5%2fV%3d10.1%2fW%3dC%2fY%3dYAHOO%2fF%3d1168823538%2fH%3dYmVzdC13b2VpZD0iMjI5NTQyMCIgY2Fycmllcj0iSU4tVU5LTk9XTiIgY29udGVudD0ibW9iaWxlX25ld3MiIGR2Y19jbHM9IjQiIHBuPSJ5YWhvb19tb2JpbGVfdXNfd2ViIiBycz0icHJpOnlhaG9vX21vYmlsZV91c193ZWI7c2VjOnlhaG9vO2NycjpJTi1VTktOT1dOOyIgc2VydmVJZD0iOTJqZlZUYzJMakZxcE9JNmZfX0RaUUdLTVRJMUxsRlN3MlhfbTVmWSIgc2l0ZUlkPSI0OTAyNTUxIiB0U3RtcD0iMTM2NDM3ODQ2OTk3MTg3MCIg%2fQ%3d-1%2fI%3d1%2fS%3d1%2fJ%3d36F70D4C&amp;U=12cle5obm%2fN%3dTWHUE2KJiVo-%2fC%3d-1%2fD%3dWFB2%2fB%3d-1%2fV%3d0"/> <!-- 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 -->

    Thanks in advance.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Oslo, Norway

    Re: QNetworkAccessManger get returns invalid XML as response for few URLs

    I am not sure if I understand what you are asking.
    http://news.yahoo.com/rss/sports seems like an RSS link, and indeed it produces an RSS XML for me
    <?xml version="1.0" encoding="utf-8"?>
    <rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <!-- fe550.global.media.ch1.yahoo.com compressed/chunked Tue Oct 22 13:18:35 UTC 2013 -->
    Seems to be a valid one.
    The excerpt in your post is an XHTML document, and the part you have shared also seems pretty valid, it has an XML header, DTD, html tag with namespace, head, etc, and ends with correct ending tags, /body, /html, and two XML comments.
    Which part is incorrect in your opinion?

  3. #3
    Registered User
    Join Date
    Oct 2013

    Re: QNetworkAccessManger get returns invalid XML as response for few URLs

    Hi wizard_hu

    Thanks for the reply.
    The issue I am facing is pretty much similar to the one in rssnews example in Qt SDK. (Qt/Qt5.0.2/5.0.2/mingw47_32/examples/quick/demos/rssnews)
    Among the news categories some shows proper news and some categores show blank (No output) when clicked.

    In my application too for the same URL I get 2 different responses.

    1) Sometimes Proper RSS XML as mentioned by you, where intented title, description tags are avaible and are parsed properly in QML using XmlListModel XmlRole like
    XmlRole { name: "title"; query: "title/string()" }

    2) DOCTYPE html with proper open and close tags but no news contents with title or description tags that are expected.

    My application is intented to fetch response from URL and show it in UI written in QML everytime.

Similar Threads

  1. WAP - Gateway received an invalid response from the upstream gateway
    By crajesh_2985 in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2009-09-26, 11:12
  2. floor() function returns invalid result
    By ravey72 in forum Symbian
    Replies: 5
    Last Post: 2007-04-26, 11:22
  3. floor() function returns invalid result
    By ravey72 in forum Open C/C++
    Replies: 4
    Last Post: 2007-04-20, 17:21
  4. Cant install NMIT - invalid response during install
    By dkguru in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2003-12-11, 13:10
  5. Replies: 0
    Last Post: 2002-11-29, 13:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts