https://github.com/pastuhov/php-xml2object
Converts XML to object
https://github.com/pastuhov/php-xml2object
converter json object parser php xml
Last synced: about 2 months ago
JSON representation
Converts XML to object
- Host: GitHub
- URL: https://github.com/pastuhov/php-xml2object
- Owner: pastuhov
- License: mit
- Created: 2017-08-07T13:56:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-08T06:09:58.000Z (almost 9 years ago)
- Last Synced: 2025-02-23T11:36:42.953Z (over 1 year ago)
- Topics: converter, json, object, parser, php, xml
- Language: PHP
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/pastuhov/php-xml2object)
[](https://scrutinizer-ci.com/g/pastuhov/php-xml2object/?branch=master)
[](https://scrutinizer-ci.com/g/pastuhov/php-xml2object/?branch=master)
[](https://packagist.org/packages/pastuhov/php-xml2object)
Converts XML to object
===========================
Input:
```xml
```
Output:
```javascript
{
"_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": "カムシャフトセッティング オイル シール"
}
]
}
]
}
```
## Features
* converts desired tags to properties
* fast
* memory saving
Installation
------------
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
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.
Usage
-----
```php
use pastuhov\xml2object\Parser;
$converter = new Parser();
$converter->xml = file_get_contents(__DIR__ . '/data/xml.xml');
$object = $converter->process();
```
Testing
-------
```bash
./vendor/bin/phpunit
```
Security
--------
If you discover any security related issues, please email pastukhov_k@sima-land.ru instead of using the issue tracker.