I am writing the following:

function getMoneyCountry($cityName, $valRQ) { $requestAddress = "http://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=".date("d/m/Y")."&date_req2=".date("d/m/Y")."&VAL_NM_RQ=".$valRQ; $xml_str = file_get_contents($requestAddress,0); $xml = new SimplexmlElement($xml_str); $count = 0; foreach($xml->ValCurs as $item) { foreach($item->Record as $new) { $money = $new->Value; } } return $money; } 

The link is obtained for example:

 <ValCurs ID="R01700" DateRange1="31/01/2012" DateRange2="31/01/2012" name="Foreign Currency Market Dynamic"> <Record Date="31.01.2012" Id="R01700J"> <Nominal>1</Nominal> <Value>17,0158</Value> </Record> </ValCurs> 

The function returns nothing.

    1 answer 1

    $xml->ValCurs you do not need. Disassemble starting at $xml->Record .

    Added by

     $requestAddress = "http://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=31/01/2012&date_req2=31/01/2012&VAL_NM_RQ=R01700"; $xml_str = file_get_contents($requestAddress); $xml = new SimplexmlElement($xml_str); foreach($xml->Record as $new) { $money = $new->Value; } echo $money; 
    • Did not help. Also empty. - Tchort
    • Updated the answer. - ling