R
R
RusticAnd2020-03-05 19:52:52
PHP
RusticAnd, 2020-03-05 19:52:52

How to parse yml type file using php?

Good evening. How to parse this

file
5e612e311d40a674477366.jpeg
and reach id and parentId.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2020-03-05
@RusticAnd

This is plain xml
Parsed by standard libraries for working with XML
https://www.php.net/manual/ru/book.simplexml.php
https://www.php.net/manual/ru/book.xmlreader.php

The YML (Yandex Market Language) standard was developed by Yandex and is based on the XML standard. The YML format provides more features and benefits than the XLS, CSV formats.

https://yandex.ru/support/partnermarket/export/yml.html
<?php
//считываем содержимое файла
$data = simplexml_load_file('file.xml');

//достукиваемся куда надо
foreach ($data->shop->categories->category as $row) {
  $id = intval($row['id']);
  $parentId = intval($row['parentId']);
  $name = strval($row);
  
  var_dump($id, $parentId, $name);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question