Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lireincore/ymlparser
YML (Yandex Market Language) parser
https://github.com/lireincore/ymlparser
parser php yandex yandex-market-language yml
Last synced: 4 months ago
JSON representation
YML (Yandex Market Language) parser
- Host: GitHub
- URL: https://github.com/lireincore/ymlparser
- Owner: lireincore
- License: mit
- Created: 2016-09-02T14:33:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-10-08T13:03:55.000Z (over 3 years ago)
- Last Synced: 2024-09-30T23:03:21.512Z (4 months ago)
- Topics: parser, php, yandex, yandex-market-language, yml
- Language: PHP
- Size: 58.6 KB
- Stars: 21
- Watchers: 0
- Forks: 16
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# YML (Yandex Market Language) parser
[![Latest Stable Version](https://poser.pugx.org/lireincore/ymlparser/v/stable)](https://packagist.org/packages/lireincore/ymlparser)
[![Total Downloads](https://poser.pugx.org/lireincore/ymlparser/downloads)](https://packagist.org/packages/lireincore/ymlparser)
[![License](https://poser.pugx.org/lireincore/ymlparser/license)](https://packagist.org/packages/lireincore/ymlparser)## About
[YML (Yandex Market Language)](https://yandex.ru/support/partnermarket/yml/about-yml.xml) streaming parser with validation.
Based on XMLReader. Suitable for large files.## Install
Add the `"lireincore/ymlparser": "^3.2"` package to your `require` section in the `composer.json` file
or
``` bash
$ php composer.phar require lireincore/ymlparser
```## Usage
```php
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](LICENSE) for more information.