sitebill / ymlparser
YML (Yandex Market Language) parser
1.0.1
2024-02-16 05:53 UTC
Requires
- php: >=5.5
- ext-xmlreader: *
This package is auto-updated.
Last update: 2025-01-16 07:52:30 UTC
README
About
YML (Yandex Market Language) streaming parser with validation. Based on XMLReader. Suitable for large files.
Install
Add the "sitebill/ymlparser": "^1.0"
package to your require
section in the composer.json
file
or
$ php composer.phar require sitebill/ymlparser
Usage
use LireinCore\YMLParser\YML; $yml = new YML(); try { $yml->parse($filepath); $date = $yml->getDate(); $shop = $yml->getShop(); if ($shop->isValid()) { $offersCount = $shop->getOffersCount(); $shopData = $shop->getData(); //... foreach ($yml->getOffers() as $offer) { if ($offer->isValid()) { $offerCategoryHierarchy = $shop->getCategoryHierarchy($offer->getCategoryId()); $offerData = $offer->getData(); //... } else { var_dump($offer->getErrors()); //... } } } else { var_dump($shop->getErrors()); //... } } catch (\Exception $e) { echo $e->getMessage(); //... }
License
The MIT License (MIT). Please see License File for more information.