Skip to content

Version 2.14.0

Compare
Choose a tag to compare
@veewee veewee released this 14 Jan 12:27
2.14.0
143c565

What's Changed

  • Add stringify and document element shortcuts to XML Document by @veewee in #67

Some functions I happen a lot are causing some verbosity. By adding them to the Document class, it makes it faster to do trivial stuff like e.g. Grabbing the document element or stringifying a part of the document.

document_element locator:

use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Locator\document_element;

$doc = Document::fromXmlFile('some.xml');
$rootElement = $doc->locate(document_element());

// Since this is a common action, there is also a shortcut:
$doc->locateDocumentElement();

Stringify

use VeeWee\Xml\Dom\Document;

$doc = Document::fromXmlFile('some.xml');

// Get full XML including the XML declaration tag:
$xml = $doc->toXmlString();

// OR, get only the XML part without declaration:
$xml = $doc->stringifyDocumentElement();

// Or stringify a specific DOM node:
$xml = $doc->stringifyNode($someNode);

Full Changelog: 2.13.0...2.14.0