Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/muhammetsafak/toxml
This library provides the simplest and most straightforward way to switch between XML and Array.
https://github.com/muhammetsafak/toxml
Last synced: 26 days ago
JSON representation
This library provides the simplest and most straightforward way to switch between XML and Array.
- Host: GitHub
- URL: https://github.com/muhammetsafak/toxml
- Owner: muhammetsafak
- License: mit
- Created: 2022-06-09T11:00:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-09T11:03:21.000Z (over 2 years ago)
- Last Synced: 2024-11-13T19:37:55.626Z (about 1 month ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# toXML
This library provides the simplest and most straightforward way to switch between XML and Array.
## Requirements
- PHP 5.6 or higger
- PHP DOM Extension## Installation
```
composer require muhammetsafak/toxml
```## Configuration
The following array is the associative configuration array declaring identifiable configurations. It can be defined while creating an object, or it can be defined later using setter methods.
```php
array(
'encode' => 'UTF-8', // String
'version' => '1.0', // String ("1.0" or "1.1")
'attributesKey' => '@attibutes', // String
'cdataKey' => '@cdata', // String
'valueKey' => '@value', // String
'useNamespaces' => false, // Boolean
'rootNodeName' => 'root', // String
);
```## Usage
### Array to XML
```php
require_once "vendor/autoload.php";$data = array();
$xml = new \MuhammetSafak\ToXML\XML();
header('Content-Type: application/xml; charset=utf-8');
echo $xml->withArray($data)
->toXML();
```### XML to Array
```php
require_once "vendor/autoload.php";$source = file_get_contents('example.xml');
$xml = new \MuhammetSafak\ToXML\XML();
$data = $xml->withXML($source)
->toArray();
```## Credits
- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) <>
## License
Copyright © 2022 [MIT Licence](./LICENSE)