PHP code example of joseph / xml-util
1. Go to this page and download the library: Download joseph/xml-util library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
joseph / xml-util example snippets
s = array(
'@attributes' => array(
'type' => 'fiction'
),
'book' => array(
array(
'@attributes' => array(
'author' => 'George Orwell'
),
'title' => '1984'
),
array(
'@attributes' => array(
'author' => 'Isaac Asimov'
),
'title' => array('@cdata'=>'Foundation'),
'price' => '$15.61'
),
array(
'@attributes' => array(
'author' => 'Robert A Heinlein'
),
'title' => array('@cdata'=>'Stranger in a Strange Land'),
'price' => array(
'@attributes' => array(
'discount' => '10%'
),
'@value' => '$18.00'
)
)
)
);
$xml = \Joseph\Xml\Util\Array2XML::getInstance();
$xmlData = $xml->createXML('books', $books);
header('Content-Type: application/xml');
echo $xmlData->saveXML();
es = '<?xml version="1.0" encoding="UTF-8"
array (
'movies' =>
array (
'movie' =>
array (
'title' => 'PHP: Behind the Parser',
'characters' =>
array (
'character' =>
array (
0 =>
array (
'name' => 'Ms. Coder',
'actor' => 'Onlivia Actora',
),
1 =>
array (
'name' => 'Mr. Coder',
'actor' => 'El ActÓr',
),
),
),
'plot' =>
array (
'@cdata' => 'So, this language. It\'s like, a programming language. Or is it a scripting language?
All is revealed in this thrilling horror spoof of a documentary.',
),
'great-lines' =>
array (
'line' => 'PHP solves all my web problems',
),
'rating' =>
array (
0 =>
array (
'@value' => '7',
'@attributes' =>
array (
'type' => 'thumbs',
),
),
1 =>
array (
'@value' => '5',
'@attributes' =>
array (
'type' => 'stars',
),
),
),
),
'@attributes' =>
array (
'type' => 'documentary',
),
),
)