2017 © Pedro PelΓ‘ez
 

library php-xml2object

Parse xml to object.

image

pastuhov/php-xml2object

Parse xml to object.

  • Tuesday, August 8, 2017
  • by pastuhov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Build Status Scrutinizer Code Quality Code Coverage Total Downloads, (*1)

Converts XML to object

Input:, (*2)

<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:, (*3)

{
    "_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., (*4)

Either run, (*5)

php composer.phar require --prefer-dist pastuhov/php-xml2object

or add, (*6)

"require-dev": {
    "pastuhov/php-xml2object": "~1.0.0"
    ...

to the require section of your composer.json file., (*7)

Usage

use pastuhov\xml2object\Parser;

$converter = new Parser();
$converter->xml = file_get_contents(__DIR__ . '/data/xml.xml');
$object = $converter->process();

Testing

./vendor/bin/phpunit

Security

If you discover any security related issues, please email pastukhov_k@sima-land.ru instead of using the issue tracker., (*8)

The Versions

08/08 2017

dev-master

9999999-dev https://github.com/pastuhov/php-xml2object

Parse xml to object.

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

07/08 2017

v1.0.0

1.0.0.0 https://github.com/pastuhov/php-xml2object

Parse xml to object.

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires