Click to See Complete Forum and Search --> : Help with XML parsing


b00tn00b2k9
03-01-2010, 04:31 AM
Hello everyone,

Need your help. Didn't have that much of experience with XML, but working with it on one project.

Below is a sample of API call that returns XML:


<RateSummary:rateSummary xsi:schemaLocation="http://www.zillow.com/static/xsd/RateSummary.xsd http://www.zillow.com/vstatic/d288affb5161120f01499a76ced68c8b/static/xsd/RateSummary.xsd">

<request>
</request>

<message>
<text>Request successfully processed</text>
<code>0</code>
</message>

<response>

<today>
<rate count="41" loanType="thirtyYearFixed">4.9</rate>
<rate count="10" loanType="fifteenYearFixed">4.25</rate>
<rate count="10" loanType="fiveOneARM">3.51</rate>
</today>

<lastWeek>
<rate count="28566" loanType="thirtyYearFixed">4.83</rate>
<rate count="12218" loanType="fifteenYearFixed">4.23</rate>
<rate count="5899" loanType="fiveOneARM">3.66</rate>
</lastWeek>
</response>
</RateSummary:rateSummary>


I need help in parsing it and using it with php, and this is what I got so far, but nothing is showing up.


<?php
$request_url = "API call that returns above xml, taken out due to ID is showing up";

$xml = simplexml_load_file($request_url) or die("feed not loading");

$thirty = $xml->RateSummary->response->today->rate->thirtyYearFixed;

echo "$thirty";
?>


Please help

Thank you in advance.

b00tn00b2k9
03-02-2010, 08:45 AM
Anybody?