Download the PHP package susina/xml-to-array without Composer

On this page you can find all versions of the php package susina/xml-to-array. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package xml-to-array

Xml to Array Converter

Test Suite Maintainability Test Coverage GitHub License

Xml to Array is a simple library to convert XML into PHP array.

The library consists in one namespace Susina\XmlToArray and two classes:

Both classes expose the same public api:

Installation

Install the library via composer:

The library depends on three php extensions, usually installed by default:

and Symfony Options Resolver component, that'll be install by composer.

Usage

Use the convert method to parse an XML string. Let's get a look at the following example:

Alternatively, you can use the static instantiator:

If you want to read and convert an xml file, you can play with FileConverter class:

and by using the static constructor:

You can save the converted array into a regular formatted php file, that you can import in some other script by include PHP statement.

For example:

The content of array_file.php is the following:

You can load your array via include statement:

Also FileConverter class has its convertAndSave method, which has the same behavior, but it accepts the name of the xml file to convert as first parameter:

Configuration

You can configure the converters by passing an associative array to the constructor, where the keys are the name of the option. The available options are the following:

mergeAttributes

Default: true

When this option is set to true, the attributes of a tag are merged into the tag it self, otherwise they're saved into a @attribute array, i.e.:

In the previous example, you can see that the name attribute is "merged" into logger array.

When this option is set to false, a @attribute array is created:

typesAsString

Default: false

The normal behavior of this library is to preserve all PHP types (boolean, numeric, null etc.). If typesAsString option is set to true all the values are considered strings:

In the previous example, if you set the property to true, all values are strings:

preserveFirstTag

Default: false

If your xml document starts with a single tag, containing all the others, the first tag is not considered as part of the resulting array:

If you want to keep this tag as the first key of your array, set this option to true:

Issues

If you find a bug or any other issue, please report it on Github.

Contributing

Please, see CONTRIBUTING.md

Licensing

This library is released under Apache-2.0 license.


All versions of xml-to-array with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-libxml Version *
ext-simplexml Version *
ext-dom Version *
symfony/options-resolver Version ^7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package susina/xml-to-array contains the following files

Loading the files please wait ....