Can you please tell how to read and display data from an XML file? There is a file of the standard yandex
<yml_catalog date='******'> <shop> <categories> <category id='34'>ΠΠΊΠΊΡΠΌΡΠ»ΡΡΠΎΡΡ</category> ....... </categories> <offers> <offer id='1' type='vendor.model' available='false'> .... <name>ΠΠΊΠΊΡΠΌΡΠ»ΡΡΠΎΡ 1</name> .... <param name='ΠΠ°ΠΏΡΡΠΆΠ΅Π½ΠΈΠ΅' unit='Π'>12.00</param> <param name='ΠΠΌΠΊΠΎΡΡΡ' unit='ΠΡ'>2.40</param> <param name='Π’ΠΈΠΏ (ΡΠ΅Ρ
Π½ΠΎΠ»ΠΎΠ³ΠΈΡ)'>Ni-Cd </param> <param name='ΠΡΠ΅ΠΌΡ Π·Π°ΡΡΠ΄ΠΊΠΈ' unit='ΠΌΠΈΠ½'>60.00</param> <param name='ΠΠ΅Ρ' unit='ΠΊΠ³'>0.32</param> <param name='ΠΠΎΠΌΠΏΠ»Π΅ΠΊΡΠ°ΡΠΈΡ'></param> </offer> <offer id='2' type='vendor.model' available='false'> .... <name>ΠΠΊΠΊΡΠΌΡΠ»ΡΡΠΎΡ 2</name> .... <param name='ΠΠ°ΠΏΡΡΠΆΠ΅Π½ΠΈΠ΅2' unit='Π'>442.00</param> <param name='ΠΠΌΠΊΠΎΡΡΡ2' unit='ΠΡ'>42.40</param> <param name='Π’ΠΈΠΏ (ΡΠ΅Ρ
Π½ΠΎΠ»ΠΎΠ³ΠΈΡ)2'>Ni-Cd </param> <param name='ΠΡΠ΅ΠΌΡ Π·Π°ΡΡΠ΄ΠΊΠΈ2' unit='ΠΌΠΈΠ½'>260.00</param> <param name='ΠΠ΅Ρ2' unit='ΠΊΠ³'>20.32</param> <param name='ΠΠΎΠΌΠΏΠ»Π΅ΠΊΡΠ°ΡΠΈΡ2'>dsadsdd</param> </offer> </offers> </shop> I already have a read cycle for all data except param. How to arrange reading exactly param equal to each offer?
Did so
foreach ($offers->shop->offers->offer[0]->param as $param) { $chname=$param['name']; $chunit=$param["unit"]; $chdigits=$param; } but it does not go through the cycle of the entire file, but only the first block of parameters (it repeats the same) and in the "offer id" settlers constantly displays ...
So:
Battery1 -param1 -param1 -param1 Battery2 -param1 -param1 -param1
How to realize this, so that the identifier where id = 1, id = 2 and so on is transmitted from the top level? Or other ways to jump and display correctly .. But I did not find how to set a condition.
So that was:
Battery1 -param1 -param1 -param1 Battery2 -param2 -param2 -param2