2017 © Pedro Peláez
 

library xml-construct

XML constructor class for PHP

image

sausin/xml-construct

XML constructor class for PHP

  • Sunday, September 10, 2017
  • by sausin
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Xml generator

Latest Version on Packagist Build Status Quality Score Scrutinizer Coverage StyleCI Total Downloads License: MIT, (*1)

A useful class to generate valid XML from a PHP array., (*2)

Installation

Run the following command in your project to get the class:, (*3)

composer require sausin/xml-construct

Usage with normal arrays

Usage is simple, (*4)

Verbose way:

$xmlGen = new XmlConstruct('ROOT')

$string = $xmlGen->fromArray($array)->getDocument();

where $array is the PHP array from which you need the XML to be generated., (*5)

Quick:

(new XmlConstruct('ROOT'))->fromArray($f)->getDocument();

returns the XML string., (*6)

In both the above examples, ROOT is the root of the XML (i.e. the first element)., (*7)

Usage with arrays when attributes are needed in XML

If used like this:, (*8)

$array = ['KEY|ATTR|VAL' => 'VALUE'];

return (new XmlConstruct('ROOT'))->fromArray($f)->getDocument();

It will result in the following XML, (*9)

<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
  <KEY ATTR="VAL">VALUE</KEY>
<ROOT>

You can add as many attributes as you like and they will all be added to the element. Neat!, (*10)

Credits

Initial inputs to the class were taken from php user contributed notes, (*11)

The Versions

10/09 2017

dev-master

9999999-dev

XML constructor class for PHP

  Sources   Download

MIT

The Requires

  • ext-xmlwriter *
  • ext-mbstring *
  • php >=7.0.0

 

The Development Requires

by Saurabh Singhvi

php xml array writer attributes xmlwriter

09/09 2017

v0.2.0

0.2.0.0

XML constructor class for PHP

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-xmlwriter *
  • ext-mbstring *

 

The Development Requires

by Saurabh Singhvi

php xml array writer attributes xmlwriter

09/09 2017

v0.1.1

0.1.1.0

XML constructor class for PHP

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-xmlwriter *
  • ext-mbstring *

 

The Development Requires

by Saurabh Singhvi

php xml array writer attributes xmlwriter

09/09 2017

v0.1.0

0.1.0.0

XML constructor class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-xmlwriter *
  • ext-mbstring *

 

The Development Requires

by Saurabh Singhvi

php xml array writer attributes xmlwriter