Download the PHP package damijanc/simple-xml without Composer

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

simple-xml

Simple wrapper for PHP (http://www.php.net/manual/en/class.domdocument.php) DOMDocument

After roughly 11 years this lib is finally getting and update. It uses a nice PHP feature - properties :D

Something about XML itself

Valid XML needs to start with xml version and encoding declaration like . XML without it is invalid.

Library by default uses UTF-8 encoding. So please make sure that all your strings are properly encoded.

XML supports multiple type of text: text, CDATA and an element.

Everything in CDATA section will be interpreted as a literal string. For example
will be interpreted as , as literal string. To be compatible with XML Specs you can use CDATA if your sting contains chars like <, >, & etc.

Text attribute will make sure that same characters will be escaped. will be , will be and will become . Up to you what you want to use.

If nothing is selected value will be used as is. Maybe I will add some formatters later like date and currency as they are supported in PHP.

Installation

Usage

We need to define a class with attributes to tell the library what kind of XML we want to have. At the moment setters and getters are no supported, but I might add that later. If property is an array we expect to have array of classes that are similarly decorated with attributes

In the example we have a collection of books. For that we need to define a collection class books and a books class, as in the example below.

Outputs:

Note on comments: As comments can appear anywhere in the XML it is hard to predict the user's intention. I decided to add comment support on the node attribute level

for example:

will result in:

I might change this implementation later. For now, I do not have any real use case.

Supported attributes

Propery attribute will add a propery to a node. It accepts two values name and value. If value is null it will be read from class property. We also have a support for multiple properties attributes that can added to mutiple class properties. Example above will attach properties to parent node as Node attribute is not defined. In the case in the example we would get

Another example with Node attribute

will result in:

Property

A word about performance

I did manage to generate XML from 50k classes in 300ms, therefor I believe it is fast enough. Would be nice if someone can confirm it.


All versions of simple-xml with dependencies

PHP Build Version
Package Version
Requires ext-dom Version *
php Version >=8.2
ext-mbstring 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 damijanc/simple-xml contains the following files

Loading the files please wait ....