Download the PHP package highwire/better-dom-document without Composer

On this page you can find all versions of the php package highwire/better-dom-document. 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?
highwire/better-dom-document
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package better-dom-document

BetterDOMDocument

Build Status Code Coverage Scrutinizer Code Quality Dependency Status

BetterDOMDocument is a handy PHP utility class for working with XML. It's a wrapper for PHP's built in DOMDocument that provides a bunch of nice shortcuts that makes working with XML in PHP a breeze. It has great built-in support for namespaces, and xpath queries.


<?php

use BetterDOMDocument\DOMDoc;

// We can load a new BetterDOMDocument from either a string or a DOMNode object
$dom = new DOMDoc($xmlstring);

// It's easy to output the entire document as an array, which is sometimes easier to work with in PHP
$array = $dom->getArray();

// It's easy to query too!
$node_list = $dom->xpath('//xpath/to/node', $optional_context_node);

// If you know you're only going to find a single DOMNode, you can use a querySingle
$dom_node = $dom->xpathSingle('//xpath/to/node');

// Swapping out DOMNodes is really easy
$dom->replace($dom_node, $replacementNode);

// Removing a node is easy
$dom->remove($dom_node);

// Most places where you want to pass a DOMNode or element, you can just pass an xpath instead
$dom->remove('//xpath/to/element/to/remove');

// The same goes for replacments
$dom->replace('//xpath/to/replace', '<xml>You can pass a string, a DOMNode, or a document</xml>');

// It's easy to output the XML
$xml = $dom->out();

// Or just output a single DOMNode
$xml = $dom->out($dom_node);

// Working with namespaced documents is made really easy
$xml = '
  <entry xmlns="http://www.w3.org/2005/Atom" xmlns:nlm="http://schema.highwire.org/NLM/Journal">
    <author>
      <name>Li Xu</name>
      <nlm:name name-style="eastern">
        <nlm:surname>Li</nlm:surname>
        <nlm:given-names>Xu</nlm:given-names>
      </nlm:name>
    </author>
  </entry>';

// If your document (like the one above) has a default namespace, you should declare 
// it's prefix as the second value when constructing a new BetterDOMDocument
$dom = new DOMDoc($xml, 'atom'); // We register the 'atom' prefix against the default namespace

// Now we can do mixed namespace queries!
$surname = $dom->querySingle('//atom:author/nlm:name/nlm:surname')->nodeValue;

// If you need to register another namespace before doing a query, thats a snap.
// Note that by default all namespace declarations in the root element are automatically registered. 
$dom->registerNamespace('kml','http://www.opengis.net/kml/2.2');

// If you want to query with CSS selectors, no problem!
$dom->select('nlm:name[@name-style="eastern"]');

All versions of better-dom-document with dependencies

PHP Build Version
Package Version
Requires symfony/css-selector Version ^6.4|^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 highwire/better-dom-document contains the following files

Loading the files please wait ....