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.
Table of contents
Download highwire/better-dom-document
More information about highwire/better-dom-document
Files in highwire/better-dom-document
Download highwire/better-dom-document
More information about highwire/better-dom-document
Files in highwire/better-dom-document
Vendor highwire
Package better-dom-document
Short Description 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.
License BSD-3-Clause
Homepage https://github.com/highwire/opensource-php-BetterDOMDocument
Package better-dom-document
Short Description 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.
License BSD-3-Clause
Homepage https://github.com/highwire/opensource-php-BetterDOMDocument
Please rate this library. Is it a good library?
highwire/better-dom-document
Rate from 1 - 5
Rated 5.00 based on 1 reviews
Rated 5.00 based on 1 reviews
Informations about the package better-dom-document
BetterDOMDocument
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
The package highwire/better-dom-document contains the following files
Loading the files please wait ....