Download the PHP package jackiedo/xml-array without Composer

On this page you can find all versions of the php package jackiedo/xml-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-array

Xml-Array

Run tests Total Downloads Latest Stable Version License

The conversion between xml and array becomes easier than ever. This package provides some very simple classes to convert XML to array and back.

Features of this package

Overview

Look at one of the following sessions to learn more about this package.

Installation

You can install this package through Composer.

Basic usage

Convert from XML

Web have two following methods:

Convert to array:

Convert to Json:

Note: The input XML can be one of types DOMDocument object, SimpleXMLElement object or well-formed XML string.

Example 1: - (Convert from XML string)

After running this piece of code $array will contain:

Example 2: - (Convert form XML object, such as SimpleXMLElement)

The result of above code is:

Example 3: - (Convert to Json)

Convert from array

We also have two following methods:

Convert to XML string:

Convert to DOMDocument object:

Example 4:

Example 5:

Advanced usage

Set configuration

If we want to change the settings for the conversion process, we can do it in the following ways:

Method 1

Note: Configuration is an array of parameters. For more details, see section Default configuration.

Method 2

Method 3

Get configuration

If we implemented the conversion process using methods 2 and 3, we can get configuration of the conversion with method:

Default configuration

For Xml2Array

For Array2Xml

Effect of configuration settings

version

Use in Data type
Xml2Array, Array2Xml string

Effect: This setting allows specifying the XML version to be generated (in Array2Xml), or reconstructed from the XML string (in Xml2Array)

encoding

Use in Data type
Xml2Array, Array2Xml string

Effect: This setting is to indicate the encoding type of the XML to be generated (in Array2Xml), or reconstructed from the XML string (in Xml2Array)

standalone

Use in Data type
Xml2Array, Array2Xml null bool

Effect: This setting is to allow the standalone directive to appear in the XML or not. If it is set to null, this directive will not appear.

Example:

Content in $xml will be

attributesKey, cdataKey, valueKey

Use in Data type
Xml2Array, Array2Xml string

Effect: This setting allows the use of special keywords to contain the values ​​of properties, CDATA section... during the conversion process.

Example: Please review the examples above for more detailed understanding.

namespacesOnRoot

Use in Data type
Xml2Array bool

Effect: This setting allows to collect all the parsed XML namespaces and place them in the root node. If it is set to false, the namespaces will be located at the nodes where it is declared.

Example: We use the Example 1 above again, but this time the configuration is different:

After running this piece of code $array will contain:

You see, the xlmns:example namespace is put at the example:with_namespace key, not at root_node as it was originally.

rootElement

Use in Data type
Array2Xml string

Effect: According to the Well-formed XML standard, the XML content is only allowed to have a single Root node. This setting allows to wrap all the elements of the original array into a single root node, instead of having to manually edit your array.

keyFixer

Use in Data type
Array2Xml bool string numeric callable

Effect:

According to the Well-formed XML standard, the tag names and attributes must satisfy a number of requirements, in which naming is specified as follows:

During conversion, array key names that violate these rules are automatically normalized. If you do not agree to this normalization, set this setting to false.

By default, this normalization replaces invalid characters with underscores (_). You can change to another character as you like.

Example:

License

MIT © Jackie Do


All versions of xml-array with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
ext-dom Version *
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 jackiedo/xml-array contains the following files

Loading the files please wait ....