×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    2

    Not able to retrieve information from <request>

    I am new to Windows Phone development, recently started to try to create a weather app, I am using API from World Weather Online (http://www.worldweatheronline.com/).

    I retrieved the below sample data from the web site (http://free.worldweatheronline.com/f...key=xxxxxxxx):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
      <request>
        <type>City</type>
        <query>Paris, France</query>
      </request>
      <current_condition>
        .......
      </current_condition>
      <weather>
        .......
      </weather>
      <weather>
        .......
      </weather>
    </data>
    I try to parse the xml and put them in a data class in C#. Below is my code:
    Code:
    XDocument doc = XDocument.Parse(e.Result);
    var data1 = from q in doc.Descendants("result")
                select new RequestData
                {
                   type = (string)q.Element("type"),
                   query = (string)q.Element("query")
                }
    This is my data class:
    Code:
    public class RequestData
    {
      public string type {get; set;}
      public string query {get; set;}
    }
    But after the above codes executed, there is no error (good), but there is no data from the data1. I tried for doc.Descendants("current_condition) and doc.Descendants("weather") and I am able to get the data into the data1, only the doc.Descendants("result") didn't give me any result.

    Anyone know why? Thanks.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2012
    Location
    Bilbao
    Posts
    53

    Re: Not able to retrieve information from <request>

    Hi ah_lun

    In the XML that you show there is no "result" element. type and query are under request node. If you modify your LiNQ query to doc.Descendants("request") your data will be retrieved ok.

    Hope This help.

  3. #3
    Registered User
    Join Date
    Mar 2013
    Posts
    2

    Re: Not able to retrieve information from <request>

    Oh ya, why did I do that, my mistake, my mistake, too careless. Thank you very much!
    It is "request", not "result".

    Thank you!

Similar Threads

  1. Retrieve CPU information
    By monika.parvanda in forum Symbian
    Replies: 2
    Last Post: 2010-11-30, 10:58
  2. retrieve SIM MCC/MNC information
    By willy_backhaus in forum Symbian
    Replies: 9
    Last Post: 2008-07-25, 19:46
  3. How to retrieve the Battery information
    By symadept in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2007-09-28, 02:38
  4. How to retrieve sender information of an SMS
    By techjamie in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2006-04-26, 08:16
  5. How to retrieve service information?
    By gadkii in forum Mobile Java General
    Replies: 1
    Last Post: 2004-03-19, 10:37

Posting Permissions

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