By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

AccuWeather xml document (can't find head/root element)

P: 14
I'm planning to publish a application in Visual Basic.Net 2012 that i want to make using the AccuWeather API

When i try to get info from some nodes in the document visual studio gives the message 'ERROR. Root/head element not found'. When i try to use the webrequest method it again gives that error, how can i make this work?

the URL = http://asus1.accu-weather.com/widget...ric=1&langId=1

Whole XML-Document:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"  encoding="utf-8"?>
  2.     <adc_database xmlns="http://www.accuweather.com">
  3.         <units>
  4.             <temp>C</temp>
  5.             <dist>KM</dist>
  6.             <speed>KPH</speed>
  7.             <pres>kPa</pres>
  8.             <prec>MM</prec>
  9.         </units>
  10.  
  11.     <local>
  12.     <city>Dinteloord</city>
  13.  
  14.     <adminArea code="NB">North Brabant</adminArea> 
  15.         <country code="NL">Netherlands</country>
  16.     <cityId>249273</cityId>
  17.     <primaryCityId>249273</primaryCityId>
  18.  
  19.     <locationKey>249273</locationKey>
  20.  
  21.     <lat>51.63652</lat> 
  22.     <lon>4.37136</lon> 
  23.     <time>17:33</time> 
  24.     <timeZone>1</timeZone>
  25.     <obsDaylight>
  26.     1
  27.     </obsDaylight>
  28.     <currentGmtOffset>2</currentGmtOffset>
  29.     <timeZoneAbbreviation>CEST</timeZoneAbbreviation>    
  30.     </local>
  31.  
  32.                 <currentconditions daylight="True">
  33.                     <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/current.aspx?p=asus1&amp;cityId=249273</url>
  34.             <observationtime>5:33 PM</observationtime>
  35.             <pressure state="Decreasing">101</pressure>
  36.             <temperature>6</temperature>
  37.             <realfeel>0</realfeel>
  38.             <humidity>56%</humidity>
  39.             <weathertext>Partly Sunny</weathertext>
  40.             <weathericon>03</weathericon>
  41.             <windgusts>27</windgusts>
  42.             <windspeed>27</windspeed>
  43.             <winddirection>NE</winddirection>
  44.             <visibility>16</visibility>
  45.             <precip>0.0</precip>
  46.             <uvindex index="0">Low</uvindex>
  47.             <dewpoint>-2</dewpoint>
  48.             <cloudcover>35%</cloudcover>
  49.             <apparenttemp>7</apparenttemp>
  50.             <windchill>2</windchill>
  51.         </currentconditions>
  52.  
  53.             <forecast>
  54.                 <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/forecast.aspx?p=asus1&amp;cityId=249273</url>
  55.  
  56.                     <day number="1">
  57.                         <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/details1.aspx?p=asus1&amp;cityId=249273</url>
  58.                     <obsdate>4/4/2013</obsdate>
  59.                     <daycode>Thursday</daycode>
  60.  
  61.                         <sunrise>7:12 AM</sunrise>
  62.                         <sunset>8:20 PM</sunset>
  63.  
  64.                     <daytime>
  65.                         <txtshort>Mostly cloudy</txtshort>
  66.                         <txtlong>Mostly cloudy</txtlong>
  67.                         <weathericon>06</weathericon>
  68.                         <hightemperature>6</hightemperature>
  69.                         <lowtemperature>-1</lowtemperature>
  70.                         <realfeelhigh>2</realfeelhigh>
  71.                         <realfeellow>-6</realfeellow>
  72.                         <windspeed>23</windspeed>
  73.                         <winddirection>ENE</winddirection>
  74.                         <windgust>53</windgust>
  75.                         <maxuv>4</maxuv>
  76.                         <rainamount>0.0</rainamount>
  77.                         <snowamount>0.00</snowamount>
  78.                         <iceamount>0.0</iceamount>
  79.                         <precipamount>0.0</precipamount>
  80.                         <tstormprob>0</tstormprob>
  81.                     </daytime>
  82.                     <nighttime>
  83.                         <txtshort>Partly cloudy</txtshort>
  84.                         <txtlong>Partly cloudy</txtlong>
  85.                         <weathericon>35</weathericon>
  86.                         <hightemperature>6</hightemperature>
  87.                         <lowtemperature>-1</lowtemperature>
  88.                         <realfeelhigh>0</realfeelhigh>
  89.                         <realfeellow>-6</realfeellow>
  90.                         <windspeed>13</windspeed>
  91.                         <winddirection>NE</winddirection>
  92.                         <windgust>24</windgust>
  93.                         <maxuv>4</maxuv>
  94.                         <rainamount>0.0</rainamount>
  95.                         <snowamount>0.00</snowamount>
  96.                         <iceamount>0.0</iceamount>
  97.                         <precipamount>0.0</precipamount>
  98.                         <tstormprob>0</tstormprob>
  99.                     </nighttime>
  100.  
  101.                     </day>
  102.  
  103.  
  104.                     <day number="2">
  105.                         <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/details2.aspx?p=asus1&amp;cityId=249273</url>
  106.                     <obsdate>4/5/2013</obsdate>
  107.                     <daycode>Friday</daycode>
  108.  
  109.                         <sunrise>7:10 AM</sunrise>
  110.                         <sunset>8:22 PM</sunset>
  111.  
  112.                     <daytime>
  113.                         <txtshort>Low clouds</txtshort>
  114.                         <txtlong>Low clouds</txtlong>
  115.                         <weathericon>08</weathericon>
  116.                         <hightemperature>7</hightemperature>
  117.                         <lowtemperature>1</lowtemperature>
  118.                         <realfeelhigh>3</realfeelhigh>
  119.                         <realfeellow>-6</realfeellow>
  120.                         <windspeed>16</windspeed>
  121.                         <winddirection>NE</winddirection>
  122.                         <windgust>24</windgust>
  123.                         <maxuv>1</maxuv>
  124.                         <rainamount>0.0</rainamount>
  125.                         <snowamount>0.00</snowamount>
  126.                         <iceamount>0.0</iceamount>
  127.                         <precipamount>0.0</precipamount>
  128.                         <tstormprob>0</tstormprob>
  129.                     </daytime>
  130.                     <nighttime>
  131.                         <txtshort>Partly cloudy</txtshort>
  132.                         <txtlong>Partly cloudy</txtlong>
  133.                         <weathericon>35</weathericon>
  134.                         <hightemperature>7</hightemperature>
  135.                         <lowtemperature>1</lowtemperature>
  136.                         <realfeelhigh>2</realfeelhigh>
  137.                         <realfeellow>-3</realfeellow>
  138.                         <windspeed>11</windspeed>
  139.                         <winddirection>NE</winddirection>
  140.                         <windgust>16</windgust>
  141.                         <maxuv>1</maxuv>
  142.                         <rainamount>0.0</rainamount>
  143.                         <snowamount>0.00</snowamount>
  144.                         <iceamount>0.0</iceamount>
  145.                         <precipamount>0.0</precipamount>
  146.                         <tstormprob>0</tstormprob>
  147.                     </nighttime>
  148.  
  149.                     </day>
  150.  
  151.  
  152.                     <day number="3">
  153.                         <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/details3.aspx?p=asus1&amp;cityId=249273</url>
  154.                     <obsdate>4/6/2013</obsdate>
  155.                     <daycode>Saturday</daycode>
  156.  
  157.                         <sunrise>7:08 AM</sunrise>
  158.                         <sunset>8:24 PM</sunset>
  159.  
  160.                     <daytime>
  161.                         <txtshort>Mostly cloudy</txtshort>
  162.                         <txtlong>Mostly cloudy</txtlong>
  163.                         <weathericon>06</weathericon>
  164.                         <hightemperature>9</hightemperature>
  165.                         <lowtemperature>-2</lowtemperature>
  166.                         <realfeelhigh>6</realfeelhigh>
  167.                         <realfeellow>-3</realfeellow>
  168.                         <windspeed>14</windspeed>
  169.                         <winddirection>NNE</winddirection>
  170.                         <windgust>21</windgust>
  171.                         <maxuv>4</maxuv>
  172.                         <rainamount>0.0</rainamount>
  173.                         <snowamount>0.00</snowamount>
  174.                         <iceamount>0.0</iceamount>
  175.                         <precipamount>0.0</precipamount>
  176.                         <tstormprob>0</tstormprob>
  177.                     </daytime>
  178.                     <nighttime>
  179.                         <txtshort>Partly cloudy</txtshort>
  180.                         <txtlong>Partly cloudy</txtlong>
  181.                         <weathericon>35</weathericon>
  182.                         <hightemperature>9</hightemperature>
  183.                         <lowtemperature>-2</lowtemperature>
  184.                         <realfeelhigh>3</realfeelhigh>
  185.                         <realfeellow>-3</realfeellow>
  186.                         <windspeed>8</windspeed>
  187.                         <winddirection>NE</winddirection>
  188.                         <windgust>16</windgust>
  189.                         <maxuv>4</maxuv>
  190.                         <rainamount>0.0</rainamount>
  191.                         <snowamount>0.00</snowamount>
  192.                         <iceamount>0.0</iceamount>
  193.                         <precipamount>0.0</precipamount>
  194.                         <tstormprob>0</tstormprob>
  195.                     </nighttime>
  196.  
  197.                     </day>
  198.  
  199.  
  200.                     <day number="4">
  201.                         <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/details4.aspx?p=asus1&amp;cityId=249273</url>
  202.                     <obsdate>4/7/2013</obsdate>
  203.                     <daycode>Sunday</daycode>
  204.  
  205.                         <sunrise>7:06 AM</sunrise>
  206.                         <sunset>8:25 PM</sunset>
  207.  
  208.                     <daytime>
  209.                         <txtshort>Partly sunny</txtshort>
  210.                         <txtlong>Partly sunny</txtlong>
  211.                         <weathericon>03</weathericon>
  212.                         <hightemperature>9</hightemperature>
  213.                         <lowtemperature>-1</lowtemperature>
  214.                         <realfeelhigh>12</realfeelhigh>
  215.                         <realfeellow>0</realfeellow>
  216.                         <windspeed>6</windspeed>
  217.                         <winddirection>E</winddirection>
  218.                         <windgust>13</windgust>
  219.                         <maxuv>4</maxuv>
  220.                         <rainamount>0.0</rainamount>
  221.                         <snowamount>0.00</snowamount>
  222.                         <iceamount>0.0</iceamount>
  223.                         <precipamount>0.0</precipamount>
  224.                         <tstormprob>0</tstormprob>
  225.                     </daytime>
  226.                     <nighttime>
  227.                         <txtshort>Cloudy</txtshort>
  228.                         <txtlong>Cloudy</txtlong>
  229.                         <weathericon>07</weathericon>
  230.                         <hightemperature>9</hightemperature>
  231.                         <lowtemperature>-1</lowtemperature>
  232.                         <realfeelhigh>3</realfeelhigh>
  233.                         <realfeellow>-1</realfeellow>
  234.                         <windspeed>6</windspeed>
  235.                         <winddirection>ESE</winddirection>
  236.                         <windgust>13</windgust>
  237.                         <maxuv>4</maxuv>
  238.                         <rainamount>0.0</rainamount>
  239.                         <snowamount>0.00</snowamount>
  240.                         <iceamount>0.0</iceamount>
  241.                         <precipamount>0.0</precipamount>
  242.                         <tstormprob>0</tstormprob>
  243.                     </nighttime>
  244.  
  245.                     </day>
  246.  
  247.  
  248.                     <day number="5">
  249.                         <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/details5.aspx?p=asus1&amp;cityId=249273</url>
  250.                     <obsdate>4/8/2013</obsdate>
  251.                     <daycode>Monday</daycode>
  252.  
  253.                         <sunrise>7:03 AM</sunrise>
  254.                         <sunset>8:27 PM</sunset>
  255.  
  256.                     <daytime>
  257.                         <txtshort>Times of clouds and sun</txtshort>
  258.                         <txtlong>Times of clouds and sun</txtlong>
  259.                         <weathericon>04</weathericon>
  260.                         <hightemperature>11</hightemperature>
  261.                         <lowtemperature>1</lowtemperature>
  262.                         <realfeelhigh>13</realfeelhigh>
  263.                         <realfeellow>1</realfeellow>
  264.                         <windspeed>5</windspeed>
  265.                         <winddirection>SE</winddirection>
  266.                         <windgust>10</windgust>
  267.                         <maxuv>3</maxuv>
  268.                         <rainamount>0.0</rainamount>
  269.                         <snowamount>0.00</snowamount>
  270.                         <iceamount>0.0</iceamount>
  271.                         <precipamount>0.0</precipamount>
  272.                         <tstormprob>0</tstormprob>
  273.                     </daytime>
  274.                     <nighttime>
  275.                         <txtshort>Mainly clear</txtshort>
  276.                         <txtlong>Mainly clear</txtlong>
  277.                         <weathericon>34</weathericon>
  278.                         <hightemperature>11</hightemperature>
  279.                         <lowtemperature>1</lowtemperature>
  280.                         <realfeelhigh>6</realfeelhigh>
  281.                         <realfeellow>0</realfeellow>
  282.                         <windspeed>5</windspeed>
  283.                         <winddirection>SE</winddirection>
  284.                         <windgust>10</windgust>
  285.                         <maxuv>3</maxuv>
  286.                         <rainamount>0.0</rainamount>
  287.                         <snowamount>0.00</snowamount>
  288.                         <iceamount>0.0</iceamount>
  289.                         <precipamount>0.0</precipamount>
  290.                         <tstormprob>0</tstormprob>
  291.                     </nighttime>
  292.  
  293.                     </day>
  294.  
  295.  
  296.                     <day number="6">
  297.                         <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/details6.aspx?p=asus1&amp;cityId=249273</url>
  298.                     <obsdate>4/9/2013</obsdate>
  299.                     <daycode>Tuesday</daycode>
  300.  
  301.                         <sunrise>7:01 AM</sunrise>
  302.                         <sunset>8:29 PM</sunset>
  303.  
  304.                     <daytime>
  305.                         <txtshort>Cloudy</txtshort>
  306.                         <txtlong>Cloudy</txtlong>
  307.                         <weathericon>07</weathericon>
  308.                         <hightemperature>14</hightemperature>
  309.                         <lowtemperature>7</lowtemperature>
  310.                         <realfeelhigh>11</realfeelhigh>
  311.                         <realfeellow>3</realfeellow>
  312.                         <windspeed>14</windspeed>
  313.                         <winddirection>SE</winddirection>
  314.                         <windgust>26</windgust>
  315.                         <maxuv>2</maxuv>
  316.                         <rainamount>0.0</rainamount>
  317.                         <snowamount>0.00</snowamount>
  318.                         <iceamount>0.0</iceamount>
  319.                         <precipamount>0.0</precipamount>
  320.                         <tstormprob>0</tstormprob>
  321.                     </daytime>
  322.                     <nighttime>
  323.                         <txtshort>Periods of rain</txtshort>
  324.                         <txtlong>Periods of rain</txtlong>
  325.                         <weathericon>18</weathericon>
  326.                         <hightemperature>14</hightemperature>
  327.                         <lowtemperature>7</lowtemperature>
  328.                         <realfeelhigh>7</realfeelhigh>
  329.                         <realfeellow>2</realfeellow>
  330.                         <windspeed>14</windspeed>
  331.                         <winddirection>SSE</winddirection>
  332.                         <windgust>23</windgust>
  333.                         <maxuv>2</maxuv>
  334.                         <rainamount>5.5</rainamount>
  335.                         <snowamount>0.00</snowamount>
  336.                         <iceamount>0.0</iceamount>
  337.                         <precipamount>5.5</precipamount>
  338.                         <tstormprob>0</tstormprob>
  339.                     </nighttime>
  340.  
  341.                     </day>
  342.  
  343.  
  344.                     <day number="7">
  345.                         <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/details7.aspx?p=asus1&amp;cityId=249273</url>
  346.                     <obsdate>4/10/2013</obsdate>
  347.                     <daycode>Wednesday</daycode>
  348.  
  349.                         <sunrise>6:59 AM</sunrise>
  350.                         <sunset>8:30 PM</sunset>
  351.  
  352.                     <daytime>
  353.                         <txtshort>A couple of showers</txtshort>
  354.                         <txtlong>A couple of showers</txtlong>
  355.                         <weathericon>12</weathericon>
  356.                         <hightemperature>13</hightemperature>
  357.                         <lowtemperature>9</lowtemperature>
  358.                         <realfeelhigh>11</realfeelhigh>
  359.                         <realfeellow>3</realfeellow>
  360.                         <windspeed>13</windspeed>
  361.                         <winddirection>SSW</winddirection>
  362.                         <windgust>21</windgust>
  363.                         <maxuv>4</maxuv>
  364.                         <rainamount>2.1</rainamount>
  365.                         <snowamount>0.00</snowamount>
  366.                         <iceamount>0.0</iceamount>
  367.                         <precipamount>2.1</precipamount>
  368.                         <tstormprob>20</tstormprob>
  369.                     </daytime>
  370.                     <nighttime>
  371.                         <txtshort>A couple of showers</txtshort>
  372.                         <txtlong>A couple of showers</txtlong>
  373.                         <weathericon>12</weathericon>
  374.                         <hightemperature>13</hightemperature>
  375.                         <lowtemperature>9</lowtemperature>
  376.                         <realfeelhigh>10</realfeelhigh>
  377.                         <realfeellow>5</realfeellow>
  378.                         <windspeed>11</windspeed>
  379.                         <winddirection>SSW</winddirection>
  380.                         <windgust>26</windgust>
  381.                         <maxuv>4</maxuv>
  382.                         <rainamount>2.7</rainamount>
  383.                         <snowamount>0.00</snowamount>
  384.                         <iceamount>0.0</iceamount>
  385.                         <precipamount>2.7</precipamount>
  386.                         <tstormprob>20</tstormprob>
  387.                     </nighttime>
  388.  
  389.                     </day>
  390.  
  391.  
  392.                     <day number="8">
  393.                         <url>http://www.accuweather.com/m/en-us/NL/NB/Dinteloord/details8.aspx?p=asus1&amp;cityId=249273</url>
  394.                     <obsdate>4/11/2013</obsdate>
  395.                     <daycode>Thursday</daycode>
  396.  
  397.                         <sunrise>6:57 AM</sunrise>
  398.                         <sunset>8:32 PM</sunset>
  399.  
  400.                     <daytime>
  401.                         <txtshort>A chance of rain</txtshort>
  402.                         <txtlong>A chance of rain</txtlong>
  403.                         <weathericon>06</weathericon>
  404.                         <hightemperature>13</hightemperature>
  405.                         <lowtemperature>6</lowtemperature>
  406.                         <realfeelhigh>10</realfeelhigh>
  407.                         <realfeellow>6</realfeellow>
  408.                         <windspeed>16</windspeed>
  409.                         <winddirection>SW</winddirection>
  410.                         <windgust>42</windgust>
  411.                         <maxuv>4</maxuv>
  412.                         <rainamount>2.3</rainamount>
  413.                         <snowamount>0.00</snowamount>
  414.                         <iceamount>0.0</iceamount>
  415.                         <precipamount>2.3</precipamount>
  416.                         <tstormprob>12</tstormprob>
  417.                     </daytime>
  418.                     <nighttime>
  419.                         <txtshort>Mostly cloudy</txtshort>
  420.                         <txtlong>Mostly cloudy</txtlong>
  421.                         <weathericon>38</weathericon>
  422.                         <hightemperature>13</hightemperature>
  423.                         <lowtemperature>6</lowtemperature>
  424.                         <realfeelhigh>7</realfeelhigh>
  425.                         <realfeellow>-1</realfeellow>
  426.                         <windspeed>19</windspeed>
  427.                         <winddirection>SW</winddirection>
  428.                         <windgust>40</windgust>
  429.                         <maxuv>4</maxuv>
  430.                         <rainamount>0.4</rainamount>
  431.                         <snowamount>0.00</snowamount>
  432.                         <iceamount>0.0</iceamount>
  433.                         <precipamount>0.4</precipamount>
  434.                         <tstormprob>20</tstormprob>
  435.                     </nighttime>
  436.  
  437.                     </day>
  438.  
  439.             </forecast>
  440.  
  441.         <copyright>Copyright 2013 AccuWeather.com</copyright>
  442.         <use>This document is intended only for use by authorized licensees of AccuWeather.com. Unauthorized use is prohibited. All Rights Reserved.</use>
  443.         <product>asus1</product>
  444.         <redistribution>Redistribution Prohibited.</redistribution>
  445.     </adc_database>
  446.  
Code i'm using :

Expand|Select|Wrap|Line Numbers
  1. Imports System.Net
  2. Imports System.IO
  3. Imports System.Xml
  4.  
  5. Public Class WeatherClient
  6. #Region "Constructor"
  7.     Public Sub New(ByVal cityname As String)
  8.         locat = cityname
  9.         getconditions()
  10.     End Sub
  11. #End Region
  12. #Region "Inner classes"
  13.     Public Class CurrentConditions
  14.         Dim cond As String
  15.         Dim tmp As String
  16.         Dim wnd As String
  17.         Dim wnddir As String
  18.         Dim rlfl As String
  19.         Dim humid As Integer
  20.         Dim visib As Integer
  21.         Dim precip As Integer
  22.         Dim uvindx As String
  23.         Dim dwpnt As Integer
  24.         Dim clcover As Integer
  25.         Dim wchill As Integer
  26.         Public ReadOnly Property Condition As String
  27.             Get
  28.                 Return cond
  29.             End Get
  30.         End Property
  31.         Public ReadOnly Property Temperature As String
  32.             Get
  33.                 Return tmp
  34.             End Get
  35.         End Property
  36.         Public ReadOnly Property WindSpeed As String
  37.             Get
  38.                 Return wnd
  39.             End Get
  40.         End Property
  41.         Public ReadOnly Property WindDirection As String
  42.             Get
  43.                 Return wnddir
  44.             End Get
  45.         End Property
  46.         Public ReadOnly Property RealFeal As String
  47.             Get
  48.                 Return rlfl
  49.             End Get
  50.         End Property
  51.         Public ReadOnly Property Humidity As Integer
  52.             Get
  53.                 Return humid
  54.             End Get
  55.         End Property
  56.         Public ReadOnly Property Visibility As Integer
  57.             Get
  58.                 Return visib
  59.             End Get
  60.         End Property
  61.         Public ReadOnly Property Precipitation As Integer
  62.             Get
  63.                 Return precip
  64.             End Get
  65.         End Property
  66.         Public ReadOnly Property UVIndex As String
  67.             Get
  68.                 Return uvindx
  69.             End Get
  70.         End Property
  71.         Public ReadOnly Property DewPoint As Integer
  72.             Get
  73.                 Return dwpnt
  74.             End Get
  75.         End Property
  76.         Public ReadOnly Property CloudCover As Integer
  77.             Get
  78.                 Return clcover
  79.             End Get
  80.         End Property
  81.         Public ReadOnly Property WindChill As Integer
  82.             Get
  83.                 Return wchill
  84.             End Get
  85.         End Property
  86.         Public Sub New(ByVal cnd As String, tmp2 As String, wnd2 As String, wnddir2 As String, rld As String, hum As String, vis As String, prec As String, uvn As String, dwn As String, clc As String, wc As String)
  87.             cond = cnd
  88.             tmp = tmp2
  89.             wnd = wnd2
  90.             wnddir = wnddir2
  91.             rlfl = rld
  92.             humid = hum
  93.             visib = vis
  94.             precip = prec
  95.             uvindx = uvn
  96.             dwpnt = dwn
  97.             clcover = clc
  98.             wchill = wc
  99.         End Sub
  100.     End Class
  101.     Public Class ForecastCondition
  102.         Dim dh As Integer
  103.         Dim dl As Integer
  104.         Dim drh As Integer
  105.         Dim drl As Integer
  106.         Dim ddwnspd As Integer
  107.         Dim ddwndir As String
  108.         Dim dramound As Integer
  109.         Dim dsamound As Integer
  110.         Dim diamound As Integer
  111.         Dim dpamount As Integer
  112.         Dim dtstormamount As Integer
  113.         Dim nh As Integer
  114.         Dim nl As Integer
  115.         Dim nrh As Integer
  116.         Dim nrl As Integer
  117.         Dim ndwnspd As Integer
  118.         Dim ndwndir As String
  119.         Dim nramound As Integer
  120.         Dim nsamound As Integer
  121.         Dim niamound As Integer
  122.         Dim npamount As Integer
  123.         Dim ntstormamount As Integer
  124.         Dim daycod As String
  125.         Public ReadOnly Property Day As String
  126.             Get
  127.                 Return daycod
  128.             End Get
  129.         End Property
  130.         Public ReadOnly Property DayTime As DayTimer
  131.             Get
  132.                 Return New DayTimer(dh, dl, drh, drl, ddwnspd, ddwndir, dramound, dsamound, diamound, dpamount, dtstormamount)
  133.             End Get
  134.         End Property
  135.         Public ReadOnly Property NightTime As NightTimer
  136.             Get
  137.                 Return New NightTimer(nh, nl, nrh, nrl, ndwnspd, ndwndir, nramound, nsamound, niamound, npamount, ntstormamount)
  138.             End Get
  139.         End Property
  140.         Public Sub New(ddh As Integer, dll As Integer, ddrh As Integer, ddrl As Integer, dddwnspd As Integer, dddwndir As String, ddramound As Integer, ddsamound As Integer, ddiamound As Integer, ddpamount As Integer, ddta As Integer _
  141.                        , nnh As Integer, nnl As Integer, ndrh As Integer, ndrl As Integer, nwndspd As Integer, nwnddir As String, ndramount As Integer, ndsamound As Integer, ndiamound As Integer, ndpamound As Integer, ndta As Integer _
  142.                        , dayc As String)
  143.             dh = ddh
  144.             dl = dll
  145.             drh = ddrh
  146.             drl = ddrl
  147.             ddwnspd = dddwnspd
  148.             ddwndir = dddwndir
  149.             dramound = ddramound
  150.             dsamound = ddsamound
  151.             diamound = ddiamound
  152.             dpamount = ddpamount
  153.             dtstormamount = ddta
  154.             nh = nnh
  155.             nl = nnl
  156.             nrh = ndrh
  157.             nrl = ndrl
  158.             ndwnspd = nwndspd
  159.             ndwndir = nwnddir
  160.             nramound = ndramount
  161.             nsamound = ndsamound
  162.             niamound = ndiamound
  163.             npamount = ndpamound
  164.             ntstormamount = ndta
  165.             daycod = dayc
  166.         End Sub
  167.         Class DayTimer
  168.             Dim h As Integer
  169.             Dim l As Integer
  170.             Dim rh As Integer
  171.             Dim rl As Integer
  172.             Dim dwnspd As Integer
  173.             Dim dwndir As String
  174.             Dim ramound As Integer
  175.             Dim samound As Integer
  176.             Dim iamound As Integer
  177.             Dim pamound As Integer
  178.             Dim tstormamound As Integer
  179.             Public ReadOnly Property High As Integer
  180.                 Get
  181.                     Return h
  182.                 End Get
  183.             End Property
  184.             Public ReadOnly Property Low As Integer
  185.                 Get
  186.                     Return l
  187.                 End Get
  188.             End Property
  189.             Public ReadOnly Property RealFeelHigh As Integer
  190.                 Get
  191.                     Return rh
  192.                 End Get
  193.             End Property
  194.             Public ReadOnly Property WindSpeed As Integer
  195.                 Get
  196.                     Return dwnspd
  197.                 End Get
  198.             End Property
  199.             Public ReadOnly Property WindDirection As String
  200.                 Get
  201.                     Return dwndir
  202.                 End Get
  203.             End Property
  204.             Public ReadOnly Property RainAmount As Integer
  205.                 Get
  206.                     Return ramound
  207.                 End Get
  208.             End Property
  209.             Public ReadOnly Property SnowAmount As Integer
  210.                 Get
  211.                     Return samound
  212.                 End Get
  213.             End Property
  214.             Public ReadOnly Property IceAmount As Integer
  215.                 Get
  216.                     Return iamound
  217.                 End Get
  218.             End Property
  219.             Public ReadOnly Property Precipitation As Integer
  220.                 Get
  221.                     Return pamound
  222.                 End Get
  223.             End Property
  224.             Public ReadOnly Property ThunderstormPropebility As Integer
  225.                 Get
  226.                     Return tstormamound
  227.                 End Get
  228.             End Property
  229.             Public Sub New(hi As Integer, lo As Integer, rhi As Integer, hlo As Integer, wndspd As Integer, wnddir As String, r As Integer, s As Integer, i As Integer, p As Integer, ta As Integer)
  230.                 h = hi
  231.                 l = lo
  232.                 rh = rhi
  233.                 rl = hlo
  234.                 dwnspd = wndspd
  235.                 dwndir = wnddir
  236.                 ramound = r
  237.                 samound = s
  238.                 iamound = i
  239.                 pamound = p
  240.                 tstormamound = ta
  241.             End Sub
  242.         End Class
  243.         Class NightTimer
  244.             Dim h As Integer
  245.             Dim l As Integer
  246.             Dim rh As Integer
  247.             Dim rl As Integer
  248.             Dim dwnspd As Integer
  249.             Dim dwndir As String
  250.             Dim ramound As Integer
  251.             Dim samound As Integer
  252.             Dim iamound As Integer
  253.             Dim pamound As Integer
  254.             Dim tstormamound As Integer
  255.             Public ReadOnly Property High As Integer
  256.                 Get
  257.                     Return h
  258.                 End Get
  259.             End Property
  260.             Public ReadOnly Property Low As Integer
  261.                 Get
  262.                     Return l
  263.                 End Get
  264.             End Property
  265.             Public ReadOnly Property RealFeelHigh As Integer
  266.                 Get
  267.                     Return rh
  268.                 End Get
  269.             End Property
  270.             Public ReadOnly Property WindSpeed As Integer
  271.                 Get
  272.                     Return dwnspd
  273.                 End Get
  274.             End Property
  275.             Public ReadOnly Property WindDirection As String
  276.                 Get
  277.                     Return dwndir
  278.                 End Get
  279.             End Property
  280.             Public ReadOnly Property RainAmount As Integer
  281.                 Get
  282.                     Return ramound
  283.                 End Get
  284.             End Property
  285.             Public ReadOnly Property SnowAmount As Integer
  286.                 Get
  287.                     Return samound
  288.                 End Get
  289.             End Property
  290.             Public ReadOnly Property IceAmount As Integer
  291.                 Get
  292.                     Return iamound
  293.                 End Get
  294.             End Property
  295.             Public ReadOnly Property Precipitation As Integer
  296.                 Get
  297.                     Return pamound
  298.                 End Get
  299.             End Property
  300.             Public ReadOnly Property ThunderstormPropebility As Integer
  301.                 Get
  302.                     Return tstormamound
  303.                 End Get
  304.             End Property
  305.             Public Sub New(hi As Integer, lo As Integer, rhi As Integer, hlo As Integer, wndspd As Integer, wnddir As String, r As Integer, s As Integer, i As Integer, p As Integer, ta As Integer)
  306.                 h = hi
  307.                 l = lo
  308.                 rh = rhi
  309.                 rl = hlo
  310.                 dwnspd = wndspd
  311.                 dwndir = wnddir
  312.                 ramound = r
  313.                 samound = s
  314.                 iamound = i
  315.                 pamound = p
  316.                 tstormamound = ta
  317.             End Sub
  318.         End Class
  319.     End Class
  320.     Public Class ForecastCollection
  321.         Inherits CollectionBase
  322.         Public Overridable Sub Add(ByVal frday As ForecastCondition)
  323.             Me.List.Add(frday)
  324.         End Sub
  325.     End Class
  326. #End Region
  327.  
  328. #Region "Properties"
  329.     Dim locat As String
  330.     Dim cond As String
  331.     Dim tmp As String
  332.     Dim wnd As String
  333.     Dim wnddir As String
  334.     Dim rlfl As String
  335.     Dim humid As Integer
  336.     Dim visib As Integer
  337.     Dim precip As Integer
  338.     Dim uvindx As String
  339.     Dim dwpnt As Integer
  340.     Dim clcover As Integer
  341.     Dim wchill As Integer
  342.     Dim fconditionlist As New ForecastCollection
  343.     Public ReadOnly Property Current As CurrentConditions
  344.         Get
  345.             Return New CurrentConditions(cond, tmp, wnd, wnddir, rlfl, humid, visib, precip, uvindx, dwpnt, clcover, wchill)
  346.         End Get
  347.     End Property
  348.     Public ReadOnly Property Forecast As ForecastCollection
  349.         Get
  350.             Return fconditionlist
  351.         End Get
  352.     End Property
  353. #End Region
  354. #Region "Functions"
  355.     Private Function getconditions()
  356.         Dim wbreq As WebRequest = WebRequest.Create("http://asus1.accu-weather.com/widget/asus1/weather-data.asp?location=" & locat & "&metric=1&langId=1")
  357.         Dim wbresp As WebResponse = wbreq.GetResponse
  358.         Dim strreader As New StreamReader(wbresp.GetResponseStream)
  359.         Dim xmlfile As String = strreader.ReadToEnd.Replace("<?xml version=""1.0""  encoding=""utf-8""?>", "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>")
  360.         Dim xmldoc As New XmlDocument
  361.         xmldoc.LoadXml(xmlfile)
  362.  
  363.         cond = xmldoc.SelectSingleNode("adc_database/currentconditions/weathertext").InnerText
  364.         tmp = xmldoc.SelectSingleNode("adc_database/currentconditions/temperature").InnerText
  365.         wnd = xmldoc.SelectSingleNode("adc_database/currentconditions/windspeed").InnerText
  366.         wnddir = xmldoc.SelectSingleNode("adc_database/currentconditions/winddirection").InnerText
  367.         rlfl = xmldoc.SelectSingleNode("adc_database/currentconditions/realfeel").InnerText
  368.         humid = xmldoc.SelectSingleNode("adc_database/currentconditions/humidity").InnerText
  369.         visib = xmldoc.SelectSingleNode("adc_database/currentconditions/visibility").InnerText
  370.         precip = xmldoc.SelectSingleNode("adc_database/currentconditions/precip").InnerText
  371.         uvindx = xmldoc.SelectSingleNode("adc_database/currentconditions/uvindex").Attributes("index").InnerText & " - " & xmldoc.SelectSingleNode("/adc_database/currentconditions/uvindex").InnerText
  372.         dwpnt = xmldoc.SelectSingleNode("adc_database/currentconditions/dewpoint").InnerText
  373.         clcover = xmldoc.SelectSingleNode("adc_database/currentconditions/cloudcover").InnerText
  374.         wchill = xmldoc.SelectSingleNode("adc_database/currentconditions/windchill").InnerText
  375.         For Each nod As XmlNode In xmldoc.SelectNodes("/adc_database/forecast/day")
  376.             Dim dh As Integer
  377.             Dim dl As Integer
  378.             Dim drh As Integer
  379.             Dim drl As Integer
  380.             Dim ddwnspd As Integer
  381.             Dim ddwndir As String
  382.             Dim dramound As Integer
  383.             Dim dsamound As Integer
  384.             Dim diamound As Integer
  385.             Dim dpamount As Integer
  386.             Dim dtstormamount As Integer
  387.             Dim nh As Integer
  388.             Dim nl As Integer
  389.             Dim nrh As Integer
  390.             Dim nrl As Integer
  391.             Dim ndwnspd As Integer
  392.             Dim ndwndir As String
  393.             Dim nramound As Integer
  394.             Dim nsamound As Integer
  395.             Dim niamound As Integer
  396.             Dim npamount As Integer
  397.             Dim ntstormamount As Integer
  398.             Dim daycod As String
  399.             Dim dt As XmlNode = nod.SelectSingleNode("daytime")
  400.             dh = dt.SelectSingleNode("hightemperature").InnerText
  401.             dl = dt.SelectSingleNode("lowtemperature").InnerText
  402.             drh = dt.SelectSingleNode("realfeelhigh").InnerText
  403.             drl = dt.SelectSingleNode("realfeellow").InnerText
  404.             ddwnspd = dt.SelectSingleNode("windspeed").InnerText
  405.             ddwndir = dt.SelectSingleNode("winddirection").InnerText
  406.             dramound = dt.SelectSingleNode("rainamount").InnerText
  407.             dsamound = dt.SelectSingleNode("snowamount").InnerText
  408.             diamound = dt.SelectSingleNode("iceamount").InnerText
  409.             dpamount = dt.SelectSingleNode("precipamount").InnerText
  410.             dtstormamount = dt.SelectSingleNode("tstormprob").InnerText
  411.             Dim nt As XmlNode = nod.SelectSingleNode("nighttime")
  412.             nh = nt.SelectSingleNode("hightemperature").InnerText
  413.             nl = nt.SelectSingleNode("lowtemperature").InnerText
  414.             nrh = nt.SelectSingleNode("realfeelhigh").InnerText
  415.             nrl = nt.SelectSingleNode("realfeellow").InnerText
  416.             ndwnspd = nt.SelectSingleNode("windspeed").InnerText
  417.             ndwndir = nt.SelectSingleNode("winddirection").InnerText
  418.             nramound = nt.SelectSingleNode("rainamount").InnerText
  419.             nsamound = nt.SelectSingleNode("snowamount").InnerText
  420.             niamound = nt.SelectSingleNode("iceamount").InnerText
  421.             npamount = nt.SelectSingleNode("precipamount").InnerText
  422.             ntstormamount = nt.SelectSingleNode("tstormamount").InnerText
  423.             daycod = nod.SelectSingleNode("daycode").InnerText
  424.             fconditionlist.Add(New ForecastCondition(dh, dl, drh, drl, ddwnspd, ddwndir, dramound, dsamound, diamound, dpamount, dtstormamount, nh, nl, nrh, nrl, ndwnspd, ndwndir, nramound, nsamound, niamound, npamount, ntstormamount, daycod))
  425.         Next
  426.     End Function
  427. #End Region
  428.  
  429. End Class
  430.  
  431.  
Apr 4 '13 #1
Share this Question
Share on Google+
9 Replies


Rabbit
Expert Mod 10K+
P: 12,347
We would need to see the code you're using to parse the XML.
Apr 4 '13 #2

P: 14
i've added the zip file with source
Apr 4 '13 #3

Rabbit
Expert Mod 10K+
P: 12,347
Please post the relevant code in the thread instead. I don't download files from people I don't know.
Apr 4 '13 #4

P: 14
added code in thread
Apr 4 '13 #5

Rabbit
Expert Mod 10K+
P: 12,347
Which line of code is throwing the error?
Apr 4 '13 #6

P: 14
line 361: xmldoc.LoadXml(xmlfile)
Apr 4 '13 #7

Rabbit
Expert Mod 10K+
P: 12,347
I don't the error you're getting when I run your code. But maybe it's because I'm using 2008 and not 2012. Have you tried defining the namespace?
Apr 4 '13 #8

P: 14
well, now that i've finaly got the accuweather lib working it says "Object is not set to a reference" at "xel.Element("weathertext").Value"

Expand|Select|Wrap|Line Numbers
  1. Imports System.Net
  2. Imports System.IO
  3. Imports System.Xml
  4. Imports System.Text
  5.  
  6. Public Class WeatherClient
  7. #Region "Enums"
  8.     Enum Language
  9.         Dutch
  10.         English
  11.     End Enum
  12.     Enum TemperatureScale
  13.         Celcius
  14.         Fahrenheit
  15.     End Enum
  16. #End Region
  17. #Region "Constructor"
  18.     Dim tmpscale As TemperatureScale
  19.     Dim lang As Language
  20.  
  21.     Public Sub New(ByVal cityname As String, ByVal language As Language, tempscale As TemperatureScale)
  22.         locat = cityname
  23.         lang = language
  24.         tmpscale = tempscale
  25.         getconditions()
  26.     End Sub
  27. #End Region
  28. #Region "Inner classes"
  29.     Public Class CurrentConditions
  30.  
  31.         Dim cond As String
  32.         Dim tmp As String
  33.         Dim wnd As String
  34.         Dim wnddir As String
  35.         Dim rlfl As String
  36.         Dim humid As Integer
  37.         Dim visib As Integer
  38.         Dim precip As Integer
  39.         Dim uvindx As String
  40.         Dim dwpnt As Integer
  41.         Dim clcover As Integer
  42.         Dim wchill As Integer
  43.         Public ReadOnly Property Condition As String
  44.             Get
  45.                 Return cond
  46.             End Get
  47.         End Property
  48.         Public ReadOnly Property Temperature As String
  49.             Get
  50.                 Return tmp
  51.             End Get
  52.         End Property
  53.         Public ReadOnly Property WindSpeed As String
  54.             Get
  55.                 Return wnd
  56.             End Get
  57.         End Property
  58.         Public ReadOnly Property WindDirection As String
  59.             Get
  60.                 Return wnddir
  61.             End Get
  62.         End Property
  63.         Public ReadOnly Property RealFeal As String
  64.             Get
  65.                 Return rlfl
  66.             End Get
  67.         End Property
  68.         Public ReadOnly Property Humidity As Integer
  69.             Get
  70.                 Return humid
  71.             End Get
  72.         End Property
  73.         Public ReadOnly Property Visibility As Integer
  74.             Get
  75.                 Return visib
  76.             End Get
  77.         End Property
  78.         Public ReadOnly Property Precipitation As Integer
  79.             Get
  80.                 Return precip
  81.             End Get
  82.         End Property
  83.         Public ReadOnly Property UVIndex As String
  84.             Get
  85.                 Return uvindx
  86.             End Get
  87.         End Property
  88.         Public ReadOnly Property DewPoint As Integer
  89.             Get
  90.                 Return dwpnt
  91.             End Get
  92.         End Property
  93.         Public ReadOnly Property CloudCover As Integer
  94.             Get
  95.                 Return clcover
  96.             End Get
  97.         End Property
  98.         Public ReadOnly Property WindChill As Integer
  99.             Get
  100.                 Return wchill
  101.             End Get
  102.         End Property
  103.         Public Sub New(ByVal cnd As String, tmp2 As String, wnd2 As String, wnddir2 As String, rld As String, hum As String, vis As String, prec As String, uvn As String, dwn As String, clc As String, wc As String)
  104.             cond = cnd
  105.             tmp = tmp2
  106.             wnd = wnd2
  107.             wnddir = wnddir2
  108.             rlfl = rld
  109.             humid = hum
  110.             visib = vis
  111.             precip = prec
  112.             uvindx = uvn
  113.             dwpnt = dwn
  114.             clcover = clc
  115.             wchill = wc
  116.         End Sub
  117.     End Class
  118.     Public Class ForecastCondition
  119.  
  120.         Dim dh As String
  121.         Dim dl As String
  122.         Dim drh As String
  123.         Dim drl As String
  124.         Dim ddwnspd As String
  125.         Dim ddwndir As String
  126.         Dim dramound As String
  127.         Dim dsamound As String
  128.         Dim diamound As String
  129.         Dim dpamount As String
  130.         Dim dtstormamount As String
  131.         Dim nh As String
  132.         Dim nl As String
  133.         Dim nrh As String
  134.         Dim nrl As String
  135.         Dim ndwnspd As String
  136.         Dim ndwndir As String
  137.         Dim nramound As String
  138.         Dim nsamound As String
  139.         Dim niamound As String
  140.         Dim npamount As String
  141.         Dim ntstormamount As String
  142.         Dim dncd As String
  143.         Dim ncnd As String
  144.         Dim daycod As String
  145.         Public ReadOnly Property Day As String
  146.             Get
  147.                 Return daycod
  148.             End Get
  149.         End Property
  150.         Public ReadOnly Property DayTime As DayTimer
  151.             Get
  152.                 Return New DayTimer(dh, dl, drh, drl, ddwnspd, ddwndir, dramound, dsamound, diamound, dpamount, dtstormamount, dncd)
  153.             End Get
  154.         End Property
  155.         Public ReadOnly Property NightTime As NightTimer
  156.             Get
  157.                 Return New NightTimer(nh, nl, nrh, nrl, ndwnspd, ndwndir, nramound, nsamound, niamound, npamount, ntstormamount, ncnd)
  158.             End Get
  159.         End Property
  160.         Public Sub New(ddh As String, dll As String, ddrh As String, ddrl As String, dddwnspd As String, dddwndir As String, ddramound As String, ddsamound As String, ddiamound As String, ddpamount As String, ddta As String _
  161.                        , nnh As String, nnl As String, ndrh As String, ndrl As String, nwndspd As String, nwnddir As String, ndramount As String, ndsamound As String, ndiamound As String, ndpamound As String, ndta As String _
  162.                        , dayc As String, dcond As String, ncond As String)
  163.             dh = ddh
  164.             dl = dll
  165.             drh = ddrh
  166.             drl = ddrl
  167.             ddwnspd = dddwnspd
  168.             ddwndir = dddwndir
  169.             dramound = ddramound
  170.             dsamound = ddsamound
  171.             diamound = ddiamound
  172.             dpamount = ddpamount
  173.             dtstormamount = ddta
  174.             nh = nnh
  175.             nl = nnl
  176.             nrh = ndrh
  177.             nrl = ndrl
  178.             ndwnspd = nwndspd
  179.             ndwndir = nwnddir
  180.             nramound = ndramount
  181.             nsamound = ndsamound
  182.             niamound = ndiamound
  183.             npamount = ndpamound
  184.             ntstormamount = ndta
  185.             daycod = dayc
  186.             dncd = dcond
  187.             ncnd = ncond
  188.         End Sub
  189.         Class DayTimer
  190.             Dim h As String
  191.             Dim l As String
  192.             Dim rh As String
  193.             Dim rl As String
  194.             Dim dwnspd As String
  195.             Dim dwndir As String
  196.             Dim ramound As String
  197.             Dim samound As String
  198.             Dim iamound As String
  199.             Dim pamound As String
  200.             Dim tstormamound As String
  201.             Dim cond As String
  202.             Public ReadOnly Property Condition As String
  203.                 Get
  204.                     Return cond
  205.                 End Get
  206.             End Property
  207.             Public ReadOnly Property High As String
  208.                 Get
  209.                     Return h
  210.                 End Get
  211.             End Property
  212.             Public ReadOnly Property Low As String
  213.                 Get
  214.                     Return l
  215.                 End Get
  216.             End Property
  217.             Public ReadOnly Property RealFeelHigh As String
  218.                 Get
  219.                     Return rh
  220.                 End Get
  221.             End Property
  222.             Public ReadOnly Property WindSpeed As String
  223.                 Get
  224.                     Return dwnspd
  225.                 End Get
  226.             End Property
  227.             Public ReadOnly Property WindDirection As String
  228.                 Get
  229.                     Return dwndir
  230.                 End Get
  231.             End Property
  232.             Public ReadOnly Property RainAmount As String
  233.                 Get
  234.                     Return ramound
  235.                 End Get
  236.             End Property
  237.             Public ReadOnly Property SnowAmount As String
  238.                 Get
  239.                     Return samound
  240.                 End Get
  241.             End Property
  242.             Public ReadOnly Property IceAmount As String
  243.                 Get
  244.                     Return iamound
  245.                 End Get
  246.             End Property
  247.             Public ReadOnly Property Precipitation As String
  248.                 Get
  249.                     Return pamound
  250.                 End Get
  251.             End Property
  252.             Public ReadOnly Property ThunderstormPropebility As String
  253.                 Get
  254.                     Return tstormamound
  255.                 End Get
  256.             End Property
  257.             Public Sub New(hi As String, lo As String, rhi As String, hlo As String, wndspd As String, wnddir As String, r As String, s As String, i As String, p As String, ta As String, cnd As String)
  258.                 h = hi
  259.                 l = lo
  260.                 rh = rhi
  261.                 rl = hlo
  262.                 dwnspd = wndspd
  263.                 dwndir = wnddir
  264.                 ramound = r
  265.                 samound = s
  266.                 iamound = i
  267.                 pamound = p
  268.                 tstormamound = ta
  269.                 cond = cnd
  270.             End Sub
  271.         End Class
  272.         Class NightTimer
  273.  
  274.             Dim h As String
  275.             Dim l As String
  276.             Dim rh As String
  277.             Dim rl As String
  278.             Dim dwnspd As String
  279.             Dim dwndir As String
  280.             Dim ramound As String
  281.             Dim samound As String
  282.             Dim iamound As String
  283.             Dim pamound As String
  284.             Dim tstormamound As String
  285.             Dim cond As String
  286.             Public ReadOnly Property Condition As String
  287.                 Get
  288.                     Return cond
  289.                 End Get
  290.             End Property
  291.             Public ReadOnly Property High As String
  292.                 Get
  293.                     Return h
  294.                 End Get
  295.             End Property
  296.             Public ReadOnly Property Low As String
  297.                 Get
  298.                     Return l
  299.                 End Get
  300.             End Property
  301.             Public ReadOnly Property RealFeelHigh As String
  302.                 Get
  303.                     Return rh
  304.                 End Get
  305.             End Property
  306.             Public ReadOnly Property WindSpeed As String
  307.                 Get
  308.                     Return dwnspd
  309.                 End Get
  310.             End Property
  311.             Public ReadOnly Property WindDirection As String
  312.                 Get
  313.                     Return dwndir
  314.                 End Get
  315.             End Property
  316.             Public ReadOnly Property RainAmount As String
  317.                 Get
  318.                     Return ramound
  319.                 End Get
  320.             End Property
  321.             Public ReadOnly Property SnowAmount As String
  322.                 Get
  323.                     Return samound
  324.                 End Get
  325.             End Property
  326.             Public ReadOnly Property IceAmount As String
  327.                 Get
  328.                     Return iamound
  329.                 End Get
  330.             End Property
  331.             Public ReadOnly Property Precipitation As String
  332.                 Get
  333.                     Return pamound
  334.                 End Get
  335.             End Property
  336.             Public ReadOnly Property ThunderstormPropebility As String
  337.                 Get
  338.                     Return tstormamound
  339.                 End Get
  340.             End Property
  341.             Public Sub New(hi As String, lo As String, rhi As String, hlo As String, wndspd As String, wnddir As String, r As String, s As String, i As String, p As String, ta As String, cnd As String)
  342.                 h = hi
  343.                 l = lo
  344.                 rh = rhi
  345.                 rl = hlo
  346.                 dwnspd = wndspd
  347.                 dwndir = wnddir
  348.                 ramound = r
  349.                 samound = s
  350.                 iamound = i
  351.                 pamound = p
  352.                 tstormamound = ta
  353.                 cond = cnd
  354.             End Sub
  355.         End Class
  356.     End Class
  357.  
  358.     Public Class ForecastCollection
  359.         Inherits CollectionBase
  360.         Public Overridable Sub Add(ByVal frday As ForecastCondition)
  361.             Me.List.Add(frday)
  362.         End Sub
  363.     End Class
  364. #End Region
  365.  
  366. #Region "Properties"
  367.     Dim locat As String
  368.     Dim cond As String
  369.     Dim tmp As String
  370.     Dim wnd As String
  371.     Dim wnddir As String
  372.     Dim rlfl As String
  373.     Dim humid As Integer
  374.     Dim visib As Integer
  375.     Dim precip As Integer
  376.     Dim uvindx As String
  377.     Dim dwpnt As Integer
  378.     Dim clcover As Integer
  379.     Dim wchill As Integer
  380.     Dim fconditionlist As New ForecastCollection
  381.     Public ReadOnly Property Current As CurrentConditions
  382.         Get
  383.             Return New CurrentConditions(cond, tmp, wnd, wnddir, rlfl, humid, visib, precip, uvindx, dwpnt, clcover, wchill)
  384.         End Get
  385.     End Property
  386.     Public ReadOnly Property Forecast As ForecastCollection
  387.         Get
  388.             Return fconditionlist
  389.         End Get
  390.     End Property
  391. #End Region
  392. #Region "Functions"
  393.     Private Function getconditions()
  394.         Dim wbreq As WebRequest
  395.         Dim wbresp As WebResponse
  396.         Select Case lang
  397.             Case Language.Dutch
  398.                 Select Case tmpscale
  399.                     Case TemperatureScale.Celcius
  400.                         wbreq = WebRequest.Create("http://asus1.accu-weather.com/widget/asus1/weather-data.asp?location=" & locat & "&metric=1&langId=6")
  401.                         wbresp = wbreq.GetResponse
  402.                     Case TemperatureScale.Fahrenheit
  403.                         wbreq = WebRequest.Create("http://asus1.accu-weather.com/widget/asus1/weather-data.asp?location=" & locat & "&metric=0&langId=6")
  404.                         wbresp = wbreq.GetResponse
  405.                 End Select
  406.             Case Language.English
  407.                 Select Case tmpscale
  408.                     Case TemperatureScale.Celcius
  409.                         wbreq = WebRequest.Create("http://asus1.accu-weather.com/widget/asus1/weather-data.asp?location=" & locat & "&metric=1&langId=1")
  410.                         wbresp = wbreq.GetResponse
  411.                     Case TemperatureScale.Fahrenheit
  412.                         wbreq = WebRequest.Create("http://asus1.accu-weather.com/widget/asus1/weather-data.asp?location=" & locat & "&metric=0&langId=1")
  413.                         wbresp = wbreq.GetResponse
  414.                 End Select
  415.         End Select
  416.  
  417.         Dim strreader As New StreamReader(wbresp.GetResponseStream, Encoding.UTF8)
  418.         Dim xml As String = strreader.ReadToEnd
  419.         Dim xdoc As XDocument = XDocument.Parse(xml)
  420.         Dim xel As XElement = xdoc.Root.Element(XName.Get("currentconditions", xdoc.Root.Name.Namespace.NamespaceName))
  421.         cond = xel.Element("weathertext").Value
  422.         tmp = xel.Element("temperature").Value
  423.         wnd = xel.Element("windspeed").Value
  424.         wnddir = xel.Element("winddirection").Value
  425.  
  426.         rlfl = xel.Element("realfeel").Value
  427.         humid = xel.Element("humidity").Value
  428.         visib = xel.Element("visibility").Value
  429.         precip = xel.Element("precip").Value
  430.         uvindx = xel.Element("uvindex").Attribute("index").Value & " - " & xdoc.Element("uvindex").Value
  431.         dwpnt = xel.Element("dewpoint").Value
  432.         clcover = xel.Element("cloudcover").Value
  433.         wchill = xel.Element("windchill").Value
  434.         For Each nod As XElement In xdoc.Root.Element(XName.Get("forecast", xdoc.Root.Name.Namespace.NamespaceName)).Elements()
  435.             Dim dh As Integer
  436.             Dim dl As Integer
  437.             Dim drh As Integer
  438.             Dim drl As Integer
  439.             Dim ddwnspd As Integer
  440.             Dim ddwndir As String
  441.             Dim dramound As Integer
  442.             Dim dsamound As Integer
  443.             Dim diamound As Integer
  444.             Dim dpamount As Integer
  445.             Dim dtstormamount As Integer
  446.             Dim nh As Integer
  447.             Dim nl As Integer
  448.             Dim nrh As Integer
  449.             Dim nrl As Integer
  450.             Dim ndwnspd As Integer
  451.             Dim ndwndir As String
  452.             Dim nramound As Integer
  453.             Dim nsamound As Integer
  454.             Dim niamound As Integer
  455.             Dim npamount As Integer
  456.             Dim ntstormamount As Integer
  457.             Dim daycod As String
  458.             Dim daycnd As String
  459.             Dim ncnd As String
  460.             Dim dt As XElement = nod.Element("daytime")
  461.             dh = dt.Element("hightemperature").Value
  462.             dl = dt.Element("lowtemperature").Value
  463.             drh = dt.Element("realfeelhigh").Value
  464.             drl = dt.Element("realfeellow").Value
  465.             ddwnspd = dt.Element("windspeed").Value
  466.             ddwndir = dt.Element("winddirection").Value
  467.             dramound = dt.Element("rainamount").Value
  468.             dsamound = dt.Element("snowamount").Value
  469.             diamound = dt.Element("iceamount").Value
  470.             dpamount = dt.Element("precipamount").Value
  471.             dtstormamount = dt.Element("tstormprob").Value
  472.             daycnd = dt.Element("txtshort").Value
  473.             Dim nt As XElement = nod.Element("nighttime")
  474.             nh = nt.Element("hightemperature").Value
  475.             nl = nt.Element("lowtemperature").Value
  476.             nrh = nt.Element("realfeelhigh").Value
  477.             nrl = nt.Element("realfeellow").Value
  478.             ndwnspd = nt.Element("windspeed").Value
  479.             ndwndir = nt.Element("winddirection").Value
  480.             nramound = nt.Element("rainamount").Value
  481.             nsamound = nt.Element("snowamount").Value
  482.             niamound = nt.Element("iceamount").Value
  483.             npamount = nt.Element("precipamount").Value
  484.             ntstormamount = nt.Element("tstormamount").Value
  485.             ncnd = nt.Element("txtshort").Value
  486.             daycod = nod.Element("daycode").Value
  487.             fconditionlist.Add(New ForecastCondition(dh, dl, drh, drl, ddwnspd, ddwndir, dramound, dsamound, diamound, dpamount, dtstormamount, nh, nl, nrh, nrl, ndwnspd, ndwndir, nramound, nsamound, niamound, npamount, ntstormamount, daycod, daycnd, ncnd))
  488.         Next
  489.     End Function
  490. #End Region
  491.  
  492. End Class
Aug 8 '13 #9

Rabbit
Expert Mod 10K+
P: 12,347
We limit threads to one question each. Please create a new thread for your new problem.
Aug 8 '13 #10

Post your reply

Sign in to post your reply or Sign up for a free account.