Не получается записать данные из mysql в xml
xml должен выглядеть так
<?xml version="1.0" encoding="utf-8"?>
<kaspi_catalog date="string"
xmlns="kaspiShopping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="kaspiShopping http://kaspi.kz/kaspishopping.xsd">
<company>CompanyName</company>
<merchantid>CompanyID</merchantid>
<offers>
<offer sku="232130213">
<model>iphone 5s white 32gb</model>
<brand>Apple</brand>
<availabilities>
<availability available="yes" storeId="myFavoritePickupPoint1"/>
<availability available="yes" storeId="myFavoritePickupPoint2"/>
</availabilities>
<price>6418</price>
</offer>
<offer sku="232130223">
<model>iphone 6s white 32gb</model>
<brand>Apple</brand>
<availabilities>
<availability available="yes" storeId="myFavoritePickupPoint1"/>
<availability available="yes" storeId="myFavoritePickupPoint2"/>
</availabilities>
<cityprices>
<cityprice cityId="750000000">193000</cityprice>
<cityprice cityId="710000000">195000</cityprice>
</cityprices>
</offer>
</offers>
</kaspi_catalog>
Вот мой код
$simplexml= new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?> <kaspi_catalog/>');
$simplexml->addAttribute('xmlns:date', 'string');
$simplexml->addAttribute('xmlns:xmlns', 'kaspiShopping');
$simplexml->addAttribute('xmlns:xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$simplexml->addAttribute('xmlns:xsi:schemaLocation', 'kaspiShopping http://kaspi.kz/kaspishopping.xsd');
$simplexml->addChild("company", "CompanyName"); // Название компании
$simplexml->addChild("merchantid", "CompanyID"); // ID Компании
//
$offers = $simplexml->addChild('offers');
foreach($result as $key => $val) {
$offer = $offers->addChild('offer');
$offer->addAttribute('offer:sku', $val['sku']);
$offer->addChild("model", $val['model']);
$offer->addChild("brand", $val['brand']);
$availabilities = $offer->addChild("availabilities");
$availabilities->addChild($val['available']);
}
file_put_contents('price_list.xml', $simplexml->asXML());
Выходит такая ошибка
Подскажите, что я делаю не так?