Answer the question
In order to leave comments, you need to log in
SimpleXML data parsing?
There is XML of this type
<?xml version="1.0" encoding="UTF-8"?>
<Owners>
<!--Информация по владельцам лицевых счетов-->
<Owner id="0000001081" name="???" email="">
<LicAccounts>
<LicAccount name="1301001"/>
<LicAccount name="1301002"/>
<LicAccount name="1301003"/>
<LicAccount name="1301009">
<Address>Какой-то адресс</Address>
<Periods>
<Period year="2014" month="04">
<DebtOnStartMonth>0</DebtOnStartMonth>
<Withheld>0</Withheld>
<Payment>0</Payment>
<DebtOnEndMonth>0</DebtOnEndMonth>
<Services>
<Service>
<Name>Коллективная антенна</Name>
<Withheld>0</Withheld>
<Payment>0</Payment>
</Service>
<Service>
<Name>Радиоточка и оповещение</Name>
<Withheld>0</Withheld>
<Payment>0</Payment>
</Service>
</Services>
</Period>
</Periods>
</LicAccount>
<LicAccount name="1301065"/>
<LicAccount name="1301073"/>
<LicAccount name="1301097"/>
<LicAccount name="1301098"/>
<LicAccount name="1301104"/>
<LicAccount name="1301138"/>
<LicAccount name="1301145"/>
</LicAccounts>
</Owner>
<Owner id="0000000962" name="Pan-American Real Estate Investment LLC" email="">
<LicAccounts>
<LicAccount name="060301179">
<Address>Какой-то адресс</Address>
<Periods>
<Period year="2014" month="04">
<DebtOnStartMonth>0</DebtOnStartMonth>
<Withheld>0</Withheld>
<Payment>99 021,17</Payment>
<DebtOnEndMonth>0</DebtOnEndMonth>
<Services>
<Service>
<Name>Техническое обслуживание</Name>
<Withheld>0</Withheld>
<Payment>24 014,21</Payment>
</Service>
<Service>
<Name>Отопление</Name>
<Withheld>0</Withheld>
<Payment>10 527,2</Payment>
</Service>
<Service>
<Name>Охрана объекта</Name>
<Withheld>0</Withheld>
<Payment>628,17</Payment>
</Service>
<Service>
<Name>Электроэнергия офисы</Name>
<Withheld>0</Withheld>
<Payment>56 420,13</Payment>
</Service>
<Service>
<Name>Холодное водоснабжение</Name>
<Withheld>0</Withheld>
<Payment>745,45</Payment>
</Service>
<Service>
<Name>Горячее водоснабжение</Name>
<Withheld>0</Withheld>
<Payment>1 311,46</Payment>
</Service>
<Service>
<Name>Водоотведение</Name>
<Withheld>0</Withheld>
<Payment>751,8</Payment>
</Service>
<Service>
<Name>Электроэнергия офисы МОП</Name>
<Withheld>0</Withheld>
<Payment>1 016,76</Payment>
</Service>
<Service>
<Name>ТО перерасчет янв-фев 14</Name>
<Withheld>0</Withheld>
<Payment>2 326,71</Payment>
</Service>
<Service>
<Name>Охр.объек перер янв-фев'14</Name>
<Withheld>0</Withheld>
<Payment>1 256,33</Payment>
</Service>
</Services>
</Period>
</Periods>
</LicAccount>
</LicAccounts>
</Owner>
<Owner>
...
</Owner>
</Owners>
$one_c= simplexml_load_file(ROOT_DIR.'/LicAcc.xml');
foreach ($one_c->Owners->xpath('//Owner') as $owners)
{
foreach($owners->LicAccounts->xpath('//LicAccount') as $licaccounts)
{
echo $licaccounts->attributes()->name."\r\n";
ob_flush();
flush();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question