问题描述:

I'm trying to get interest rate value from the XML file given in the URL. I would just get the notice saying: "Trying to get the property on a non-object".

Can anyone help me figure this out please?

Here is my code:

$url = "http://www.suomenpankki.fi/en/tilastot/korot/Pages/tilastot_markkina-_ja_hallinnolliset_korot_euribor_korot_today_xml_en__XML.aspx?output=XML ";

$eurorate = file_get_contents($url);

$name="rate";

$newFile = 'xml/'.$name."xml";

file_put_contents($newFile,$eurorate);

$interest = @simplexml_load_file($newFile);

$date = $interest->period['value'];

$interest_rate=$interest->rate[14]->intr['value'];

XML file:

<Report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="euribor_korot_today_xml_en" xsi:schemaLocation="euribor_korot_today_xml_en http://inrs1/ReportServer?%2Ftilastot%2Fmarkkina-_ja_hallinnolliset_korot%2Feuribor_korot_today_xml_en&rs%3AFormat=XML&rs%3ASnapshot=2015-10-12T09%3A00%3A20&rc%3ASchema=True" Name="euribor_korot_today_xml_en" title="Euribor rates 09 Oct 2015" description="The Euribor rate is calculated on the rate quoted by prime banks, operating in the euro area. There are approximately 50 banks represented in the arrangement, in Finland's case it is Nordea. The quotation is given at midday, Finnish time. The calculation is made leaving the 15% lowest and highest offers out and by calcualtion the unweighted average. " creator="Bank of Finland" frequency="D" date_format="yyyy-MM-dd" updated="2015-10-12">

<data provider="Reuters">

<period_Collection>

<period value="2015-10-09">

<matrix1_Title_Collection>

<rate name="1 week (act/360)">

<intr value="-0.149"/>

</rate>

<rate name="1 week (act/365)">

<intr value="-0.151"/>

</rate>

<rate name="2 week (act/360)">

<intr value="-0.144"/>

</rate>

<rate name="2 week (act/365)">

<intr value="-0.146"/>

</rate>

<rate name="1 month (act/360)">

<intr value="-0.113"/>

</rate>

<rate name="1 month (act/365)">

<intr value="-0.115"/>

</rate>

<rate name="2 month (act/360)">

<intr value="-0.073"/>

</rate>

<rate name="2 month (act/365)">

<intr value="-0.074"/>

</rate>

<rate name="3 month (act/360)">

<intr value="-0.049"/>

</rate>

<rate name="3 month (act/365)">

<intr value="-0.050"/>

</rate>

<rate name="6 month (act/360)">

<intr value="0.028"/>

</rate>

<rate name="6 month (act/365)">

<intr value="0.028"/>

</rate>

<rate name="9 month (act/360)">

<intr value="0.072"/>

</rate>

<rate name="9 month (act/365)">

<intr value="0.073"/>

</rate>

<rate name="12 month (act/360)">

<intr value="0.139"/>

</rate>

<rate name="12 month (act/365)">

<intr value="0.141"/>

</rate>

</matrix1_Title_Collection>

</period>

</period_Collection>

</data>

</Report>

相关阅读:
Top