Download the PHP package arc/xml without Composer

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

ARC: Ariadne Component Library

Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License

A flexible component library for PHP


The Ariadne Component Library is a spinoff from the Ariadne Web Application Framework and Content Management System [ http://www.ariadne-cms.org/ ]

arc/xml

This component provides a unified xml parser and writer. The writer allows for readable and always correct xml in code, without using templates. The parser is a wrapper around both DOMDocument and SimpleXML.

The parser and writer also work on fragments of XML. The parser also makes sure that the output is identical to the input. When converting a node to a string, \arc\xml will return the full xml string, including tags. If you don't want that, you can always access the 'nodeValue' property to get the original SimpleXMLElement.

Finally the parser also adds the ability to use basic CSS selectors to find elements in the XML.

Example code:

And parsing it:

Installation

This library requires PHP 7.1 or higher. It is installable and autoloadable via Composer as arc/xml.

Parsing XML

Examples

For these examples we'll use the following XML

Getting the title

result:

The parser returns the full XML element by default. If you just want the contents, you must be explicit:

result:

Instead of the default in SimpleXML, arc\xml must be explicitly told to get the value of the node using the nodeValue property.

Setting the title

As you can see, there is no need to mention the nodeValue here, the name 'title' is enough to select the correct element. It would not make sense to turn the title into another tag entirely here. You can still use the nodeValue if you prefer though.

Getting attributes

result

Just what you would expect, even though there is a namespace in there. When you use a namespace that the parser hasn't been told about before, it will simply look it up in the document and re-use it.

Since attributes aren't XML nodes, there is no nodeValue. Attributes are always returned as just a string.

Setting attributes

This adds the title-attribute if it wasn't there before, or updates it if it was.

Removing attributes

Searching the document

result:

Again, you get the full XML of the result and it is just an array. (Its been joined here using implode for clarity).

The find() method accepts most CSS2.0 selectors. For now you can't enter more than one selector, so you can't select 'item, channel' for instance. Either use the SimpleXML xpath() method or run multiple queries.

Searching using namespaces

result:

Again, you get the full XML by default. But in addition, though you've used a namespace alias not known in the document ( dublincore ), find() returns the <dc:date> element for you. The alias is different, but the namespace is the same and that is what matters.

The find() method always returns an array, which may be empty. By using current() you get the first element found, or null if nothing was found.

Supported CSS Selectors

The following CSS selectors are supported:

SimpleXML

The parsed XML behaves almost identical to a SimpleXMLElement, with the exceptions noted above. So you can access attributes just like SimpleXMLElement allows:

You can walk through the node tree:

Any method or property available in SimpleXMLElement is included in \arc\xml parsed data.

DOMElement methods

In addition to SimpleXMLElement methods, you can also call any method that is available in DOMElement.

Parsing fragments

The arc\xml parser accepts partial XML content. It doesn't require a single root element.

result:


All versions of xml with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
arc/base Version ~3.0
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 arc/xml contains the following files

Loading the files please wait ....