PHP code example of edujugon / xml-mapper
1. Go to this page and download the library: Download edujugon/xml-mapper 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/ */
edujugon / xml-mapper example snippets
'providers' => array(
...
Edujugon\XMLMapper\Providers\XMLMapperServiceProvider::class
)
'aliases' => array(
...
'XMLMapper' => Edujugon\XMLMapper\Facades\XMLMapper::class,
)
$mapper = new Edujugon\XMLMapper\XMLMapper();
$mapper->loadXML($xmlData);
$mapper = new Edujugon\XMLMapper\XMLMapper($xmlData);
$mapper = XMLMapper::loadXML($xmlData);
$value = $mapper->getvalue(['first-tag','second-tag','my-tag']);
$att = $mapper->getAttribute('id',['first-tag','second-tag','my-tag']);
$newXmlMapper = $mapper->getElement('tag-name');
$arrayOFXmlMappers = $mapper->getElement('tag-name');
$value = $mapper->findValue('my-tag');
$att = $mapper->findAttribute('my-att','my-tag');
$att = $mapper->findAttribute('my-att');
$att = $mapper->findAttributeWhere('my-att',['id'=>1,'dev'=> 'edu',['name','!=','john']])
$obj = $mapper->findAttributes(['att-1','att-2'],'my-tag')
$name = $obj->name;
$dev = $obj->dev;
$obj = $mapper->findAttributesWhere(['att-1','att-2'],['dev'=> 'edu',['name','!=','john']])
$list = $mapper->findAllAttributesOf('tag-name');
$list = $mapper->findAllAttributesOfWhere('tag-name',['dev'=> 'edu',['name','!=','john']])
$mapper->replaceTagName(
[
'a10:author' => 'author',
'a10:name' => 'name',
'a10:updated' => 'updated'
]
);
$mapper->mergeXML($newXml, 'desiredParentTag');
$mapper->wrapWith('tagName');
$mapper-addAttributes(['attr1' => 'value1', 'attr2' => 'value2']);
or
$mapper-addAttributes(['attr1' => 'value1', 'attr2' => 'value2'], 'tagName');