2017 © Pedro Peláez
 

package easy-xml

Convert your data to xml string easily.

image

rummykhan/easy-xml

Convert your data to xml string easily.

  • Tuesday, November 21, 2017
  • by rummykhan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 400 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 194 % Grown

The README.md

EasyXML

This package helps you in converting your data to XML easily. This package is independent of any php framework. But I took care of two popular frameworks specifically, (*1)

  1. For use in Laravel
  2. For use in YII 2.0

To use in any framework

Installation

Install using composer, (*2)

composer require rummykhan/easy-xml

Wit the constructor initialization you can use it any framework you may like., (*3)

$rootNode = new XmlNode('person');

$educationNode = new XmlNode('education');
$educationNode->addAttributes(['MOE' => 'SXC', 'DAE' => 'COE', 'BA' => 'UOS']);
$rootNode->addChildNode($educationNode);

$jobNode = new XmlNode('job');

$jobNode->addAttribute('first', 'https://best-bf.com');
$jobNode->addAttribute('second', 'https://infamous.ae');
$jobNode->addAttribute('third', 'https://awok.com');
$jobNode->addAttribute('fourth', 'https://helpbit.com');

$rootNode->addChildNode($jobNode)
    ->setDeclaration(XmlDeclaration::V1);

// since it implements php __toString() method
dd((string)$rootNode);
// OR
dd($rootNode->toString());

will output, (*4)

<?xml version="1.0" encoding="UTF-8"?>
<person>
   <education MOE="SXC" DAE="COE" BA="UOS" />
   <job first="https://best-bf.com" second="https://infamous.ae" third="https://awok.com" fourth="https://helpbit.com" />
</person>

RummyKhan\EasyXml\XmlNode API

addChildNode

To add a child node to XmlNode. e.g., (*5)

$rootNode = new XmlNode('employees');
$employeeNode = new XmlNode('employee');

$rootNode->addChildNode($employeeNode);

setValue

To set the value of the node. Node can either have other node as children or it has a primitive value., (*6)

$rootNode = new XmlNode('name');
$rootNode->setValue('rummykhan');

addAttribute

To add the attribute for the xml node., (*7)

$rootNode = new XmlNode('person');
$rootNode->addAttribute('age', 30);

addAttributes

To add multiple attributes for the xml node. e.g., (*8)

$rootNode = new XmlNode('person');
$rootNode->addAttributes([
    'name' => 'rummykhan',
    'age' => 30
]);

setDeclaration

To set the Xml declaration, (*9)

$rootNode = new XmlNode('employees');
$rootNode->setDeclaration('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>');

toString

To convert xml single node or xml node hierarchy to xml string., (*10)

$rootNode = new XmlNode('employees');
dd($rootNode->toString());

Contact

rehan_manzoor@outlook.com, (*11)

The Versions

21/11 2017

dev-master

9999999-dev

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Rehan Manzoor

xml laravel 5 convert data to xml yii 2.0

21/11 2017

1.0.6

1.0.6.0

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Rehan Manzoor

xml laravel 5 convert data to xml yii 2.0

21/11 2017

1.0.5

1.0.5.0

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Rehan Manzoor

xml laravel 5 convert data to xml yii 2.0

21/11 2017

dev-dev

dev-dev

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Rehan Manzoor

xml laravel 5 convert data to xml yii 2.0

21/11 2017

1.0.4

1.0.4.0

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Rehan Manzoor

xml laravel 5 convert data to xml yii 2.0

21/11 2017

1.0.3

1.0.3.0

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Rehan Manzoor

xml laravel 5 convert data to xml yii 2.0

21/11 2017

1.0.2

1.0.2.0

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Rehan Manzoor

xml laravel 5 convert data to xml yii 2.0

21/11 2017

1.0.1

1.0.1.0

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Rehan Manzoor

xml laravel 5 convert data to xml yii 2.0

21/11 2017

1.0.0

1.0.0.0

Convert your data to xml string easily.

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Rehan Manzoor

laravel xml convert data to xml yii 2.0