PHP code example of desperado / xml-bundle
1. Go to this page and download the library: Download desperado/xml-bundle 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/ */
desperado / xml-bundle example snippets
use Desperado\XmlBundle\Model\XmlGenerator;
$params = [
'Request' => [
'@ns' => [
'0_xmlns' => ['prefix' => 'xsi', 'uri' => 'http//www.w3.org/2001/XMLSchema-instance'],
'1_xmlns' => ['prefix' => 'xsd', 'uri' => 'http//www.w3.org/2001/XMLSchema'],
],
'@attrib' => [
'Id' => 100,
'Service' => 200,
'xmlns' => 'http://ekassir.com/ekassir/PaySystem/Server/eKassirV3Protocol'
],
'PaymentParameters' => [
'@attrib' => ['xmlns' => ''],
'Parameter' => [
'@attrib' => ['Name' => 'account'],
'@value' => 'emptyAccount'
]
]
]
];
$xmlGenerator = new XmlGenerator;
echo $xmlGenerator->generateFromArray($params);
use Desperado\XmlBundle\Model\XmlPrepare;
use Desperado\XmlBundle\Model\XmlGenerator;
$params = [
'Details' => [
'PaymentParameters' => [
'first_node' => 'first_node_value',
'second_node' => 'second_node_value'
]
]
];
$xmlPrepare = new XmlPrepare;
$xmlGenerator = new XmlGenerator;
echo $xmlGenerator->setRootName('request')->generateFromArray($xmlPrepare->prepareArrayBeforeToXmlConvert($params));
use Desperado\XmlBundle\Model\XmlReader;
$xmlString = '<?xml version="1.0" encoding="UTF-8"
Array
(
[Details] => Array
(
[PaymentParameters] => Array
(
[first_node] => first_node_value
[second_node] => second_node_value
)
)
)