GitXplorerGitXplorer
k

converter

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
26bb76d27d9edcc383bfd216577b1cf73f5dcb86

Update README.md

kkenlog committed 3 months ago
Verified
2ec96a42475494c3c17a406948392a4ae9dc59b1

Update README.md

kkenlog committed 3 months ago
Verified
a11d3ee0e5677c64a7170df20960a238c0675fd9

Update _config.yml

kkenlog committed 4 years ago
Verified
be76416e2e659ccc4971b370b54f25c8bc2eeb97

Update _config.yml

kkenlog committed 4 years ago
Unverified
030f67d6d8749d609354a58fd41c0d223e6156fb

Set theme jekyll-theme-cayman

kkenlog committed 4 years ago
Verified
e438b56ea443365434707cbfd3c000b0d248218f

Update README.md

kkenlog committed 4 years ago

README

The README file for this repository.

GitHub Packagist Downloads

Converter 📄 🔄 📃

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

Example conversion to CSV

<?php

require 'vendor/autoload.php';

use Kenlog\Converter;

// @constructor new Converter(string $xml);
$converterCSV = new Converter('products.xml');

// @method setCSV(string $csv, string $xpath, array $columns, string $separator = ',', int $skipLines = 0);
$converterCSV->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

require 'vendor/autoload.php';

use Kenlog\Converter;

// @constructor new Converter(string $xml);
$converterJSON = new Converter('products.xml');

// @method setJSON(string $jsonFile);
$converterJSON->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

require 'vendor/autoload.php';

use Kenlog\Converter;

// @constructor new Converter(string $xml);
$converterArray = new Converter('products.xml');

// @array getArray();
$products = $converterArray->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;
}

👷 Any contribution will be highly appreciated

Clone the repository:

git clone https://github.com/kenlog/converter.git

🐛 Issues

Please create an issue for any bugs you've found.

Author

License

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