Answer the question
In order to leave comments, you need to log in
How to get the content of a specific tag (PHP)?
Good evening! I want to get the dollar and euro exchange rate from the xml file of the Central Bank of the Russian Federation website. I found the file using simplexml_load_file. Can you please tell me how to access the tag
? I have already written the $currency chain (this is the simplexml_load_file variable) -> Valute -> Value. Obviously, with such a chain, the call goes to the first counter Valute tag, but how to substitute ID in the chain? At first I dug on the Internet, I didn’t find it, they either go through the entire list, which is not necessary, or they turn to the Valute [i] index, but what if the bank swaps currencies? By the way, do not tell me if there are any conditions for using this data? Or is it enough to point to the source? Thanks to! <valute id="R01235">
Answer the question
In order to leave comments, you need to log in
$items = $simplexml->xpath('valute[@id="R01235"]');
$item = $items[0];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question