Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kenlog/converter

Simple converter from XML to CSV or JSON or Array
https://github.com/kenlog/converter

converter csv-export php72 xml-converter xmltoarray xmltocsv xmltojson

Last synced: about 1 month ago
JSON representation

Simple converter from XML to CSV or JSON or Array

Awesome Lists containing this project

README

        

![GitHub](https://img.shields.io/github/license/kenlog/Converter?style=flat-square)
![Packagist Downloads](https://img.shields.io/packagist/dt/kenlog/converter)

# Converter :page_facing_up: :arrows_counterclockwise: :page_with_curl:
Simple converter from XML to CSV or JSON or Array

## Getting Started

## Install with composer
by default composer will download the latest stable version.
```
composer require kenlog/converter
```

## Usage - [examples](examples)

### Example conversion to CSV
```php
setCSV('products.csv','//Product',['Code', 'Description', 'Um', 'Qty']);

// @var bool success
if ($converterCSV->success) {
echo 'The XML file has been converted to CSV';
} else {
echo 'The XML file was not converted to CSV';
}
```

### Example conversion to JSON
```php
setJSON('products.json');

// @var bool success
if ($converterJSON->success) {
echo 'The XML file has been converted to JSON';
} else {
echo 'The XML file was not converted to JSON';
}
```

### Example conversion to Array
```php
getArray();

// The result will be an array containing all records
foreach ($products['Product'] as $product) {
echo $product['Code'] . PHP_EOL;
echo $product['Description'] . PHP_EOL;
echo $product['Um'] . PHP_EOL;
echo $product['Qty'] . PHP_EOL;
}
```

:construction_worker: Any contribution will be highly appreciated
------------
Clone the repository:
```console
git clone https://github.com/kenlog/converter.git
```
:bug: Issues
------------
Please [create an issue](https://github.com/kenlog/converter/issues) for any bugs you've found.

## Author

* **Valentino Pesce** - [Kenlog](https://github.com/kenlog)

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE) file for details