Input:
<root>
<detail detailid="3721899" formattedoem="90311-71001" manufacturer="TOYOTA">
<properties>
<property code="Name" detailpropertyid="6086730" locale="en_US" property="Наименование"/>
<property property="Наименование" rate="5" value="カムシャフトセッティング オイル シール"/>
<property rate="5" value="0.035 кг"/>
</properties>
</detail>
<detail detailid="4445210" formattedoem="20621-71001" manufacturer="TOYOTA">
<properties>
<property code="Name" detailpropertyid="6086730" locale="en_US" property="Наименование"/>
<property property="Наименование" rate="5" value="カムシャフトセッティング オイル シール"/>
</properties>
</detail>
</root>
Output:
{
"_tagName": "root",
"_childrenProperty": "children",
"children": [
{
"_tagName": "detail",
"_childrenProperty": "properties",
"detailid": "3721899",
"formattedoem": "90311-71001",
"manufacturer": "TOYOTA",
"properties": [
{
"_tagName": "property",
"_childrenProperty": null,
"code": "Name",
"detailpropertyid": "6086730",
"locale": "en_US",
"property": "Наименование"
},
{
"_tagName": "property",
"_childrenProperty": null,
"property": "Наименование",
"rate": "5",
"value": "カムシャフトセッティング オイル シール"
},
{
"_tagName": "property",
"_childrenProperty": null,
"rate": "5",
"value": "0.035 кг"
}
]
},
{
"_tagName": "detail",
"_childrenProperty": "properties",
"detailid": "4445210",
"formattedoem": "20621-71001",
"manufacturer": "TOYOTA",
"properties": [
{
"_tagName": "property",
"_childrenProperty": null,
"code": "Name",
"detailpropertyid": "6086730",
"locale": "en_US",
"property": "Наименование"
},
{
"_tagName": "property",
"_childrenProperty": null,
"property": "Наименование",
"rate": "5",
"value": "カムシャフトセッティング オイル シール"
}
]
}
]
}
- converts desired tags to properties
- fast
- memory saving
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist pastuhov/php-xml2object
or add
"require-dev": {
"pastuhov/php-xml2object": "~1.0.0"
...
to the require section of your composer.json
file.
use pastuhov\xml2object\Parser;
$converter = new Parser();
$converter->xml = file_get_contents(__DIR__ . '/data/xml.xml');
$object = $converter->process();
./vendor/bin/phpunit
If you discover any security related issues, please email [email protected] instead of using the issue tracker.