Download the PHP package tcja/domdxmlparser without Composer

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

Menu

DOMDXMLParser

DOMDXMLParser is a class that can handle multiple CRUD tasks with XML files

This class currently only supports the following XML layout examples

Simple layout with one level node along with attributes (default layout) :

or a layout with 2 levels nodes comprising each data in a single node without any attributes :

How to install

Using composer : composer require tcja/domdxmlparser

or just download the class itself and install it manually

Read, check and compare data methods

Check a node existance by its value or by its attribute/value pair : suppose we want to check a user's e-mail existence from an email attribute :

to check that same e-mail using the non-attribute layout style :

Collect data from a specific node and have them stored in an array : suppose we want to get all data from the user with the e-mail [email protected] :

Output :

To do that according to the non-attribute layout style, just select the node by its value :

Get an attribute value from a specific node :

To do that according to the non-attribute layout style, pass the tag name as an argument to getValue() method :

Get a node value :

To do that according to the non-attribute layout style, pass the tag name as an argument to getValue() method :

Get all nodes data :

Output :

Sort the results by a specific attribute : suppose we want to sort the previous data by email in ascending order :

Output :

To sort in descending order, pass DESC value to sortBy() second attribute like so :

Please note that sortBy() method also sorts numerical values.

Get a specific attribute value from all nodes : suppose we want to get all users e-mail :

Output :

Get data from all nodes which match a specific attribute value : suppose we want to get data from the users that have an admin type account :

Output :

Compare an attribute value with the previous one in the same node : suppose we want to check if the password input from a login form corresponds to the password stored in the XML file :

Get the highest value amongst all nodes : suppose we want to get the user with the highest ID :

Get the total amount of items from the DOM :

Edit, add and remove data methods

Add a new node in the XML file : suppose we want to add a new user, first we pass the name of the node and then we can pass an array of attributes and values :

If using the non-attribute layout style, by default the nodes values will be written in pure text, if we want to use CDATA instead, we just have to set true to addNode()'s third argument like so :

If there is no data in the XML file yet and you want to add a node using the non-attribute layout style, please use the setLayoutStyleNoAttributes() method and pass true to its attribute before using addNode() method like so :

If there is already data in the XML file, we don't need to specify the layout style as the class will guess it for us and add the data accordingly.

Change node values : suppose we want to change some data for user with ID "3" (change its email and its user type to "user") :

To change only one attribute value, we can just pass the attribute as a the first argument and its value to the second one :

Add a new attribute : suppose we want to add a new attribute/value to that user, just pass the new attribute and value as you would do to change one like shown above :

Remove an attribute : suppose we want to remove the newly created attribute above, we would just pass false as the second argument to changeData() method from the targeted attribute like so :

Change specific attributes to all nodes : suppose we want to reset all users name to "NAME RESET", we pick account node and then pass an array with the new value to changeData() method :

Set new node value : suppose we want to set a new node value using CDATA to the user with the name "Third User", use setValue() method :

to do it using pure text, use setTextValue() method instead :

Remove a node from the XML file : suppose the user with the e-mail "[email protected]" wants to remove his account :

Requirements

PHP 7.1 or above

PSR-4 autoload if using composer

Dependencies

PHP-Unit for unit testing

License

Released under the MIT License

Changelog

v1.2 :

Added a new way to remove an attribute, renamed a method and added unit testing :

v1.1.1 :

Fixed minor bugs (DOMDXMLParser::getTotalItems() method wasn't calculating items correctly), improved code, added a new method :

v1.1 :

Fixed some bugs, improved some code, also added three new methods :


All versions of domdxmlparser with dependencies

PHP Build Version
Package Version
Requires php 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 tcja/domdxmlparser contains the following files

Loading the files please wait ....