Weather forecast XML parser

Discussion in 'PHP' started by goliathus, Jun 7, 2008.

  1. #1
    Hi,

    I need parse weather.com forecast xml. Could you help me pls?

    I can send you sample XML by PM..

    Thanks
     
    goliathus, Jun 7, 2008 IP
  2. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #2
    Lordo, Jun 7, 2008 IP
  3. goliathus

    goliathus Peon

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I can pay for a script parsing this XML into PHP array ... anybody interested?

    I need only forecast from this XML ... so <cc> and <dayf> tags and it's inner tags ... no promo links :)

    XML example:

    
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!--This document is intended only for use by authorized licensees of The Weather Channel. Unauthorized use is prohibited. Copyright 1995-2005, The Weather Channel Interactive, Inc. All Rights Reserved.-->
    <weather ver="2.0">
      <head>
        <locale>en_US</locale>
        <form>MEDIUM</form>
        <ut>F</ut>
        <ud>mi</ud>
        <us>mph</us>
        <up>in</up>
        <ur>in</ur>
      </head>
      <loc id="30339">
        <dnam>Atlanta, GA (30339)</dnam>
        <tm>9:47 AM</tm>
        <lat>33.87</lat>
        <lon>-84.47</lon>
        <sunr>6:26 AM</sunr>
        <suns>8:47 PM</suns>
        <zone>-4</zone>
      </loc>
      <lnks type="prmo">
        <link pos="1">
          <l>http://www.weather.com/allergies?par=xoap&amp;site=textlink&amp;cm_ven=XOAP&amp;cm_cat=TextLink&amp;cm_pla=Link1&amp;cm_ite=Allergies</l>
          <t>Local Pollen Reports</t>
        </link>
        <link pos="2">
          <l>http://www.weather.com/flights?par=xoap&amp;site=textlink&amp;cm_ven=XOAP&amp;cm_cat=TextLink&amp;cm_pla=Link2&amp;cm_ite=BusinessTraveler</l>
          <t>Airport Conditions</t>
        </link>
        <link pos="3">
          <l>http://www.weather.com/garden?par=xoap&amp;site=textlink&amp;cm_ven=XOAP&amp;cm_cat=TextLink&amp;cm_pla=Link3&amp;cm_ite=Garden</l>
          <t>Lawn and Garden Weather</t>
        </link>
        <link pos="4">
          <l>http://www.weather.com/traffic?par=xoap&amp;site=textlink&amp;cm_ven=XOAP&amp;cm_cat=TextLink&amp;cm_pla=Link4&amp;cm_ite=Traffic</l>
          <t>Rush Hour Traffic</t>
        </link>
      </lnks>
      <cc>
        <lsup>6/7/08 9:25 AM EDT</lsup>
        <obst>The Weather Channel, GA</obst>
        <tmp>82</tmp>
        <flik>87</flik>
        <t>Sunny</t>
        <icon>32</icon>
        <bar>
          <r>30.24</r>
          <d>steady</d>
        </bar>
        <wind>
          <s>calm</s>
          <gust>N/A</gust>
          <d>0</d>
          <t>CALM</t>
        </wind>
        <hmid>68</hmid>
        <vis>8.0</vis>
        <uv>
          <i>2</i>
          <t>Low</t>
        </uv>
        <dewp>71</dewp>
        <moon>
          <icon>4</icon>
          <t>Waxing Crescent</t>
        </moon>
      </cc>
      <dayf>
        <lsup>6/7/08 9:07 AM EDT</lsup>
        <day d="0" t="Saturday" dt="Jun 7">
          <hi>93</hi>
          <low>72</low>
          <sunr>6:26 AM</sunr>
          <suns>8:47 PM</suns>
          <part p="d">
            <icon>34</icon>
            <t>Mostly Sunny</t>
            <wind>
              <s>4</s>
              <gust>N/A</gust>
              <d>251</d>
              <t>WSW</t>
            </wind>
            <bt>M Sunny</bt>
            <ppcp>20</ppcp>
            <hmid>53</hmid>
          </part>
          <part p="n">
            <icon>29</icon>
            <t>Partly Cloudy</t>
            <wind>
              <s>3</s>
              <gust>N/A</gust>
              <d>267</d>
              <t>W</t>
            </wind>
            <bt>P Cloudy</bt>
            <ppcp>20</ppcp>
            <hmid>68</hmid>
          </part>
        </day>
        <day d="1" t="Sunday" dt="Jun 8">
          <hi>96</hi>
          <low>72</low>
          <sunr>6:26 AM</sunr>
          <suns>8:48 PM</suns>
          <part p="d">
            <icon>34</icon>
            <t>Mostly Sunny</t>
            <wind>
              <s>5</s>
              <gust>N/A</gust>
              <d>72</d>
              <t>ENE</t>
            </wind>
            <bt>M Sunny</bt>
            <ppcp>20</ppcp>
            <hmid>51</hmid>
          </part>
          <part p="n">
            <icon>33</icon>
            <t>Mostly Clear</t>
            <wind>
              <s>4</s>
              <gust>N/A</gust>
              <d>164</d>
              <t>SSE</t>
            </wind>
            <bt>M Clear</bt>
            <ppcp>20</ppcp>
            <hmid>65</hmid>
          </part>
        </day>
        <day d="2" t="Monday" dt="Jun 9">
          <hi>93</hi>
          <low>71</low>
          <sunr>6:26 AM</sunr>
          <suns>8:48 PM</suns>
          <part p="d">
            <icon>37</icon>
            <t>Isolated T-Storms</t>
            <wind>
              <s>8</s>
              <gust>N/A</gust>
              <d>168</d>
              <t>SSE</t>
            </wind>
            <bt>Iso T-Storms</bt>
            <ppcp>30</ppcp>
            <hmid>56</hmid>
          </part>
          <part p="n">
            <icon>29</icon>
            <t>Partly Cloudy</t>
            <wind>
              <s>2</s>
              <gust>N/A</gust>
              <d>220</d>
              <t>SW</t>
            </wind>
            <bt>P Cloudy</bt>
            <ppcp>20</ppcp>
            <hmid>69</hmid>
          </part>
        </day>
        <day d="3" t="Tuesday" dt="Jun 10">
          <hi>88</hi>
          <low>71</low>
          <sunr>6:26 AM</sunr>
          <suns>8:49 PM</suns>
          <part p="d">
            <icon>37</icon>
            <t>Isolated T-Storms</t>
            <wind>
              <s>4</s>
              <gust>N/A</gust>
              <d>247</d>
              <t>WSW</t>
            </wind>
            <bt>Iso T-Storms</bt>
            <ppcp>30</ppcp>
            <hmid>61</hmid>
          </part>
          <part p="n">
            <icon>11</icon>
            <t>Showers</t>
            <wind>
              <s>0</s>
              <gust>N/A</gust>
              <d>276</d>
              <t>CALM</t>
            </wind>
            <bt>Showers</bt>
            <ppcp>30</ppcp>
            <hmid>70</hmid>
          </part>
        </day>
        <day d="4" t="Wednesday" dt="Jun 11">
          <hi>90</hi>
          <low>70</low>
          <sunr>6:26 AM</sunr>
          <suns>8:49 PM</suns>
          <part p="d">
            <icon>37</icon>
            <t>Isolated T-Storms</t>
            <wind>
              <s>3</s>
              <gust>N/A</gust>
              <d>273</d>
              <t>W</t>
            </wind>
            <bt>Iso T-Storms</bt>
            <ppcp>30</ppcp>
            <hmid>60</hmid>
          </part>
          <part p="n">
            <icon>29</icon>
            <t>Partly Cloudy</t>
            <wind>
              <s>0</s>
              <gust>N/A</gust>
              <d>68</d>
              <t>CALM</t>
            </wind>
            <bt>P Cloudy</bt>
            <ppcp>20</ppcp>
            <hmid>74</hmid>
          </part>
        </day>
      </dayf>
    </weather>
    
    Code (markup):
     
    goliathus, Jun 7, 2008 IP