ordinary9843 / xml-master
Convert array to XML format
Installs: 1 499
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >7.1
Requires (Dev)
- phpunit/phpunit: >7.0
This package is auto-updated.
Last update: 2024-12-23 10:04:56 UTC
README
Intro
Convert array to XML format.
Requirements
This library has the following requirements:
- PHP 7.1+
Installation
Require the package via composer:
composer require ordinary9843/xml-master
Usage
Example usage:
<?php require './vendor/autoload.php'; use Ordinary9843\XmlMaster; $xmlMaster = new XmlMaster(); // Set XML version. $xmlMaster->setVersion('1.0'); // Set XML encoding type. $xmlMaster->setEncoding('UTF-8'); /** * Array conversion to XML. * * Output: * * <root> * <user> * <name>Software Engineer</name> * <email>ordinary9843@gmail.com</email> * <title>Sortware Engineer</title> * <website>https://github.com/ordinary9843</website> * </user> * </root> */ $xmlMaster->convert([ 'user' => [ 'name' => 'Software Engineer', 'email' => 'ordinary9843@gmail.com', 'title' => 'Sortware Engineer', 'website' => 'https://github.com/ordinary9843' ] ]); /** * Convert array to XML and save the result. */ $xmlMaster->save('./test.xml', [ 'user' => [ 'name' => 'Software Engineer', 'email' => 'ordinary9843@gmail.com', 'title' => 'Sortware Engineer', 'website' => 'https://github.com/ordinary9843' ] ]); /** * Get all messages. * * Output: [ * '[INFO] Message.', * '[ERROR] Message.' * ] */ $xmlMaster->getMessages();
Testing
composer test
Licenses
(The MIT License)