我正在尝试从URL中提供的XML文件中获取利率值。我只是得到通知说:“试图在非对象上获取属性”。
有人能帮我解决这个问题吗?
这是我的代码:
$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文件:
<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>