Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/kenlog/converter
- Owner: kenlog
- License: mit
- Created: 2020-05-17T16:29:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-25T12:49:06.000Z (5 months ago)
- Last Synced: 2024-09-29T19:41:48.298Z (about 2 months ago)
- Topics: converter, csv-export, php72, xml-converter, xmltoarray, xmltocsv, xmltojson
- Language: PHP
- Homepage: https://kenlog.github.io/converter/
- Size: 41 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
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