[eluser]codelearn[/eluser]
Hi guys,
I am having trouble accessing a certain value in an XML feed. I think this is VERY easy, I just can't find the right syntax.
Code:
<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="01003">
<dnam>Amherst, MA (01003)</dnam>
<tm>5:50 PM</tm>
<lat>42.39</lat>
<lon>-72.53</lon>
<sunr>7:19 AM</sunr>
<suns>4:26 PM</suns>
<zone>-5</zone>
</loc>
−
<lnks type="prmo">
−
<link pos="1">
−
<l>
http://www.weather.com/allergies?par=xoap&site=textlink&cm_ven=XOAP&cm_cat=TextLink&cm_pla=Link1&cm_ite=Allergies
</l>
<t>Local Pollen Reports</t>
</link>
−
<link pos="2">
−
<l>
http://www.weather.com/flights?par=xoap&site=textlink&cm_ven=XOAP&cm_cat=TextLink&cm_pla=Link2&cm_ite=BusinessTraveler
</l>
<t>Airport Conditions</t>
</link>
−
<link pos="3">
−
<l>
http://www.weather.com/garden?par=xoap&site=textlink&cm_ven=XOAP&cm_cat=TextLink&cm_pla=Link3&cm_ite=Garden
</l>
<t>Lawn and Garden Weather</t>
</link>
−
<link pos="4">
−
<l>
http://www.weather.com/traffic?par=xoap&site=textlink&cm_ven=XOAP&cm_cat=TextLink&cm_pla=Link4&cm_ite=Traffic
</l>
<t>Rush Hour Traffic</t>
</link>
</lnks>
−
<cc>
<lsup>12/29/08 4:55 PM EST</lsup>
<obst>Chicopee Falls, MA</obst>
<tmp>35</tmp>
<flik>29</flik>
<t>Cloudy</t>
<icon>26</icon>
−
<bar>
<r>29.84</r>
<d>falling</d>
</bar>
−
<wind>
<s>8</s>
<gust>N/A</gust>
<d>300</d>
<t>WNW</t>
</wind>
<hmid>63</hmid>
<vis>10.0</vis>
−
<uv>
<i>0</i>
<t>Low</t>
</uv>
<dewp>24</dewp>
−
<moon>
<icon>2</icon>
<t>Waxing Crescent</t>
</moon>
</cc>
−
<dayf>
<lsup>12/29/08 5:06 PM EST</lsup>
−
<day d="0" t="Monday" dt="Dec 29">
<hi>N/A</hi>
<low>29</low>
<sunr>7:19 AM</sunr>
<suns>4:26 PM</suns>
−
<part p="d">
<icon>44</icon>
<t>N/A</t>
−
<wind>
<s>N/A</s>
<gust>N/A</gust>
<d>N/A</d>
<t>N/A</t>
</wind>
<bt>N/A</bt>
<ppcp>50</ppcp>
<hmid>N/A</hmid>
</part>
−
<part p="n">
<icon>46</icon>
<t>Snow Showers / Wind Late</t>
−
<wind>
<s>20</s>
<gust>N/A</gust>
<d>236</d>
<t>SW</t>
</wind>
<bt>Snow Showers</bt>
<ppcp>50</ppcp>
<hmid>67</hmid>
</part>
</day>
−
<day d="1" t="Tuesday" dt="Dec 30">
<hi>36</hi>
<low>24</low>
<sunr>7:20 AM</sunr>
<suns>4:26 PM</suns>
−
<part p="d">
<icon>24</icon>
<t>Partly Cloudy / Wind</t>
−
<wind>
<s>25</s>
<gust>N/A</gust>
<d>290</d>
<t>WNW</t>
</wind>
<bt>P Cldy/Wind</bt>
<ppcp>10</ppcp>
<hmid>50</hmid>
</part>
−
<part p="n">
<icon>46</icon>
<t>Snow Showers Late</t>
−
<wind>
<s>12</s>
<gust>N/A</gust>
<d>276</d>
<t>W</t>
</wind>
<bt>Snow Showers</bt>
<ppcp>60</ppcp>
<hmid>59</hmid>
</part>
</day>
−
<day d="2" t="Wednesday" dt="Dec 31">
<hi>29</hi>
<low>6</low>
<sunr>7:20 AM</sunr>
<suns>4:27 PM</suns>
−
<part p="d">
<icon>16</icon>
<t>Snow</t>
−
<wind>
<s>13</s>
<gust>N/A</gust>
<d>8</d>
<t>N</t>
</wind>
<bt>Snow</bt>
<ppcp>80</ppcp>
<hmid>62</hmid>
</part>
−
<part p="n">
<icon>14</icon>
<t>Snow Shower</t>
−
<wind>
<s>15</s>
<gust>N/A</gust>
<d>307</d>
<t>NW</t>
</wind>
<bt>Snow Showers</bt>
<ppcp>60</ppcp>
<hmid>63</hmid>
</part>
</day>
</dayf>
</weather>
How would I go about accessing, say, any of the variables from "Monday". Please let me know if this is confusing.
The XML parser is below, if it is needed for this:
Code:
$xml = file_get_contents($this->xmlserver.$this->zipcode.'?cc=*&dayf=1&link=xoap&prod=xoap∥='.$this->partner.'&key;='.$this->license);
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $xml, $values, $index);
xml_parser_free($xml_parser);
foreach ($values as $row) {
if(isset($row['value'])) {
if($row['level']==3) {
$this->{strtolower($row['tag'])} = $row['value'];
}
}
}
Thanks so much.