Skip to content

citysites/ymlparser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YML (Yandex Market Language) parser

This is the fork of lirencore\ymlparser with some fixes not merged with main library for the this moment:

  • node value "0" should not be replaced with "null",
  • the fix for the boolean uppercase-value attribute validation.

About

YML (Yandex Market Language) streaming parser with validation. Based on XMLReader. Suitable for large files.

Install

Add in the composer.json file the

"lireincore/ymlparser": "^3.2"

package to your require section and

{
    "type": "git",
    "url": "https://github.com/citysites/ymlparser"
},

in repositories section

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.

About

YML (Yandex Market Language) parser

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%