NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #1106 most downloaded on Packagist
XML without worries
Latest stable
4.14.0
Last release 1 months ago
16 Oct 2026
Release timing varies
gaps range from 9 days to 9 months
Nearly every release is documented
notes for 59 of 59 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
60 releases · first in 2021
Drag across the ruler to compare, or tap a release to open it.
Faster in-memory writes and libxml issue detection by @veewee in #112
Full Changelog: 4.13.0...4.14.0
Full Changelog: https://github.com/veewee/xml/compare/4.13.0...4.14.0
Use correct FQCN in bootstrap function map keys by @veewee in #110
Full Changelog: 4.12.0...4.13.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Full Changelog: https://github.com/veewee/xml/compare/4.12.0...4.13.0
Add disallow_doctype() configurator (no-DOCTYPE policy guard) by @veewee in #107
Full Changelog: 4.11.0...4.12.0
Full Changelog: https://github.com/veewee/xml/compare/4.11.0...4.12.0
Add promote_namespaces function by @veewee in #103
Full Changelog: https://github.com/veewee/xml/compare/4.10.0...4.11.0
Add to_unsafe_legacy_document mapper by @veewee in #102
Full Changelog: 4.9.0...4.10.0
Full Changelog: https://github.com/veewee/xml/compare/4.9.0...4.10.0
Work around C14N duplicate xmlns bug on libxml 2.9.14 by @veewee in #101
Full Changelog: 4.8.0...4.9.0
Full Changelog: https://github.com/veewee/xml/compare/4.8.0...4.9.0
Ship with stubs Full Changelog : 4.7.0...4.8.0
Full Changelog: 4.7.0...4.8.0
Full Changelog: https://github.com/veewee/xml/compare/4.7.0...4.8.0
Split into PSL components by @veewee in #100
Full Changelog: https://github.com/veewee/xml/compare/4.6.0...4.7.0
Replace abandoned azjezz/psl with php-standard-library/php-standard-library by @veewee in #98
Full Changelog: 4.5.0...4.6.0
Full Changelog: https://github.com/veewee/xml/compare/4.5.0...4.6.0
Add support for azjezz/psl v5.0+ by @veewee in https://github.com/veewee/xml/pull/94
Full Changelog: https://github.com/veewee/xml/compare/4.4.0...4.5.0
Allow webmozart/assert at version 2 by @aubryfr in https://github.com/veewee/xml/pull/93
webmozart/assert at version 2 by @aubryfr in https://github.com/veewee/xml/pull/93Full Changelog: https://github.com/veewee/xml/compare/4.3.0...4.4.0
Php 85 upgrade 4.x by @veewee in https://github.com/veewee/xml/pull/91
Full Changelog: https://github.com/veewee/xml/compare/4.2.0...4.3.0
Inherit XMLNS during encoding like we did in v3 by @veewee in https://github.com/veewee/xml/pull/88
Full Changelog: https://github.com/veewee/xml/compare/4.1.0...4.2.0
Allow empty docs inside configurators like pretty_print by @veewee in https://github.com/veewee/xml/pull/86
Full Changelog: https://github.com/veewee/xml/compare/4.0.0...4.1.0
PHP84 : Add spec compliance by @veewee in https://github.com/veewee/xml/pull/74
Starting from v4, this package opt's-in to the spec compliance mode that has been released in PHP 8.4. Since these changes cannot be ported to older PHP versions, v3 of this package will be maintained actively for a longer period. This will give you a grace period to upgrade your PHP versions, packages, ... This little bump in the road is necessary to provide you with a better, more stable and spec-compliant package in the future.
Support table:
| veewee/xml | PHP | LTS |
|---|---|---|
| 3.0 - 3.1 | 8.1, 8.2, 8.3 | NO |
| 3.2 | 8.2, 8.3 | NO |
| 3.3+ | 8.2, 8.3, 8.4 | YES |
| 4.0+ | 8.4+ | YES |
Full Changelog: https://github.com/veewee/xml/compare/3.2.0...4.0.0
PHP84 : Add spec compliance by @veewee in https://github.com/veewee/xml/pull/74
Full Changelog: https://github.com/veewee/xml/compare/3.2.0...4.0.0-alpha1
Use correct FQCN in bootstrap function map keys by @veewee in #111
Full Changelog: 3.7.0...3.8.0
Full Changelog: https://github.com/veewee/xml/compare/3.7.0...3.8.0
Add promote_namespaces function (3.x backport of #103 ) by @veewee in #104
Full Changelog: 3.6.0...3.7.0
Full Changelog: https://github.com/veewee/xml/compare/3.6.0...3.7.0
Replace abandoned azjezz/psl with php-standard-library/php-standard-library by @veewee in https://github.com/veewee/xml/pull/99
Full Changelog: https://github.com/veewee/xml/compare/3.5.0...3.6.0
Add support for azjezz/psl v5.0+ by @veewee in https://github.com/veewee/xml/pull/96
Full Changelog: https://github.com/veewee/xml/compare/3.4.0...3.5.0
Update symfony/finder requirement from ^6.1 to ^6.1 || ^7.0 by @dependabot[bot] in https://github.com/veewee/xml/pull/84
Full Changelog: https://github.com/veewee/xml/compare/3.3.0...3.4.0
Add support for PHP 8.4 for XML v3 by @veewee in https://github.com/veewee/xml/pull/82
Full Changelog: https://github.com/veewee/xml/compare/3.2.0...3.3.0
Fix new psalm reports + test compatibility by @veewee in https://github.com/veewee/xml/pull/73
ℹ️
Bump to PSL 3, implies bumping PHP to >8.2 People on 8.1 can still use older versions of this package. (it's all pretty stable right now)
Full Changelog: https://github.com/veewee/xml/compare/3.1.0...3.2.0
Fix psalm 5.20 by @veewee in https://github.com/veewee/xml/pull/69
Full Changelog: https://github.com/veewee/xml/compare/3.0.0...3.1.0
This new version introduces 1 breaking change in the Reader component:
This new version introduces 1 breaking change in the Reader component:
Instead of providing the results as a string, this string are now wrapped with a MatchingNode.
This allows us to also provide information like the matched NodeSequence and some shortcut functions for converting this XML into a DOM Document or decoded version of the XML.
If you are using the Reader of v2, you will have to change your implementation to support the MatchingNode instead of the string result from previous version.
An example:
use VeeWee\Xml\Dom\Configurator;
use VeeWee\Xml\Reader\Signal;
use function VeeWee\Xml\Reader\Matcher\element_name;
use function VeeWee\Xml\Reader\Matcher\sequence;
$xml = <<<XML
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
<service id="kernel" class="TicketSwap\Kernel" public="true" synthetic="true" autoconfigure="true">
<tag xmlns="http://symfony.com/schema/dic/tag-1" name="controller.service_arguments">1</tag>
<tag xmlns="http://symfony.com/schema/dic/tag-2" name="routing.route_loader">2</tag>
</service>
</services>
</container>
XML;
$reader = VeeWee\Xml\Reader\Reader::fromXmlString($xml);
$signal = new Signal();
foreach ($reader->provide(element_name('tag'), $signal) as $tag) {
// New result of the reader is now a DTO that contains both the XML and node sequence.
var_dump(
// This is the previous matched XML `string`
$tag->xml(),
// Contains a match function so that you can run a secondary matcher on the result.
// Can be handy if you are matching on multiple paths in one read for example.
$tag->matches(sequence(
element_name('container'),
element_name('services'),
element_name('service'),
element_name('tag')
)),
// You can now directly pull the xml into a DOM Document with or without a DOM configurator.
$tag->intoDocument(Configurator\canonicalize()),
// Or decode it directly using xml_decode:
$tag->decode(Configurator\canonicalize()),
// You can get access to the current matching NodeSequence data:
$tag->nodeSequence(),
);
// Stops reading on first `tag` match.
$signal->stop();
}
Following functions were deprecated in v2 and are removed from v3:
Reader\Matcher\node_name: Use Reader\Matcher\element_name instead.Reader\Matcher\node_attribute: Use Reader\Matcher\attribute_value instead.Full Changelog: https://github.com/veewee/xml/compare/2.14.0...3.0.0
Add stringify and document element shortcuts to XML Document by @veewee in https://github.com/veewee/xml/pull/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.
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();
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: https://github.com/veewee/xml/compare/2.13.0...2.14.0
Improve writer implementation by @veewee in https://github.com/veewee/xml/pull/65
Full Changelog: https://github.com/veewee/xml/compare/2.12.0...2.13.0
PHP 8.3 Support by @veewee in https://github.com/veewee/xml/pull/63
Full Changelog: https://github.com/veewee/xml/compare/2.11.2...2.12.0
Revert "More stable node loading" by @veewee in https://github.com/veewee/xml/pull/64
This commit reverts The more stable node loading from https://github.com/veewee/xml/pull/61. It turns out that this solution introduces some more problems.
It seems like a better idea to wait for a fix in PHP than to deal with these newer issues in this package.
Full Changelog: https://github.com/veewee/xml/compare/2.11.1...2.11.2
More stable node loading by @veewee in https://github.com/veewee/xml/pull/61
Full Changelog: https://github.com/veewee/xml/compare/2.11.0...2.11.1
Explain how the reader component works by @veewee in https://github.com/veewee/xml/pull/59
Full Changelog: https://github.com/veewee/xml/compare/2.10.0...2.11.0
Improve function autoloading by @veewee in https://github.com/veewee/xml/pull/57
Full Changelog: https://github.com/veewee/xml/compare/2.9.0...2.10.0
Introduce the nested() XML Reader matcher by @veewee in https://github.com/veewee/xml/pull/56
Provide nested matchers that represents parts of an XML tree.
It can be used similar to the //user xpath operator to search on any matching node at any level in the XML
Given:
<root>
<users>
<user locale="nl">Jos</user>
<user>Bos</user>
<user>Mos</user>
</users>
</root>
This matcher will grab the user element with locale="nl"
use \VeeWee\Xml\Reader\Matcher;
Matcher\nested(
// Breakpoint 1: <root />
Matcher\document_element(),
// Breakpoint 2: <user locale="nl">Jos</user>
// Searches for all elements that matches `<user />` and attribute `locale="nl"` in the `<root />` document.
// Note that you can skip matching on `<users />` here : it's not an exact matcher
Matcher\all(
Matcher\element_name('user'),
Matcher\attribute_value('locale', 'nl')
)
);
Every provided matcher acts as a breakpoint in the NodeSequence for the next matcher,
making it composable with the exact XML tree sequence matcher as well.
use \VeeWee\Xml\Reader\Matcher;
Matcher\nested(
// Breakpoint 1: <root />
Matcher\document_element(),
// Breakpoint 2: <user />
// The nested matcher will provide the NodeSequence starting from the element after previous match.
// The sequence will basically receive: 'users > user'
Matcher\sequence(
// Level 0: The element inside <root /> at level 0 must exactly match <users />
Matcher\element_name('users'),
// Level 1: The element inside <root /> at level 1 must exactly match <user />
Matcher\element_name('user'),
),
// Breakpoint 3: <email />
// After matching a sequence, you can still continue matching deeper or adding even more sequences:
Matcher\element_name('email')
);
Full Changelog: https://github.com/veewee/xml/compare/2.8.0...2.9.0
Provide better reader matchers by @veewee in https://github.com/veewee/xml/pull/55
This release introduces a broad set of new and improved Reader matchers:
Deprecates:
Example:
<root>
<users>
<user locale="nl">Jos</user>
<user>Bos</user>
<user locale="nl">Mos</user>
</users>
</root>
This matcher will grab the user elements with locale="nl"
use VeeWee\Xml\Reader\Reader;
use \VeeWee\Xml\Reader\Matcher;
$matcher = Matcher\sequence(
// Level 0: <root />
Matcher\document_element(),
// Level 1: <users />
Matcher\element_name('users'),
// Level 2: <user locale="nl" />
Matcher\all(
Matcher\element_name('user'),
Matcher\attribute_value('locale', 'nl')
)
);
$matches = Reader::fromXmlFile($file)->provide($matcher);
Full Changelog: https://github.com/veewee/xml/compare/2.7.0...2.8.0
Fix testsuite for libxml 2.11 by @veewee in https://github.com/veewee/xml/pull/52
Full Changelog: https://github.com/veewee/xml/compare/2.6.0...2.7.0
Fix mutable nodeList reference during traversal by @veewee in https://github.com/veewee/xml/pull/50
Full Changelog: https://github.com/veewee/xml/compare/2.5.0...2.6.0
Allows you to keep track of the document uri, even if you are using an in-memory string. Internally, it sets DOMDocument::$documentURI, which gets use
Allows you to keep track of the document uri, even if you are using an in-memory string.
Internally, it sets DOMDocument::$documentURI, which gets used as file in the error handling issues component.
use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Configurator\document_uri;
$wsdl = 'http://myservice.com?wsdl';
Document::fromXmlString(
$loadFromHttp($wsdl),
document_uri($wsdl)
);
Provides shortcut functions to the NodeList that allow you to grab a single element OR throw a customizable exception instead.
$item = $list->expectAt(0, 'Expected an element at index %s');
$item = $list->expectFirst('Expected a first element.');
$item = $list->expectSingle('Expected exactly 1 element, got %s');
$item = $list->expectLast('Expected an element at index %s');
Full Changelog: https://github.com/veewee/xml/compare/2.4.0...2.5.0
Improve types by @veewee in https://github.com/veewee/xml/pull/46
Full Changelog: https://github.com/veewee/xml/compare/2.3.0...2.4.0
Upgrade tools and improve types by @veewee in https://github.com/veewee/xml/pull/45
Full Changelog: https://github.com/veewee/xml/compare/2.2.0...2.3.0
Re-allow callable function inputs by @veewee in https://github.com/veewee/xml/pull/43
Full Changelog: https://github.com/veewee/xml/compare/2.1.0...2.2.0
Support callables on main classes again by @veewee in https://github.com/veewee/xml/pull/42
Full Changelog: https://github.com/veewee/xml/compare/2.0.0...2.1.0
Introduce PHP82 + PSL2 support by @veewee in https://github.com/veewee/xml/pull/40
PSL2 is currently not supported by @veewee in https://github.com/veewee/xml/pull/37
Full Changelog: https://github.com/veewee/xml/compare/1.6.0...1.7.0
Added function element_encode() by @lykciv in https://github.com/veewee/xml/pull/32
$element = [
'Lorem' => 'Ipsum',
];
element_encode($element);
Output
<Lorem>Ipsum</Lorem>
Full Changelog: https://github.com/veewee/xml/compare/1.5.0...1.6.0
Add DOM assertion methods by @veewee in https://github.com/veewee/xml/pull/30
final class SecurityLocator
{
public function __invoke(Document $document): \DOMElement
{
return assert_element(
$document->xpath(new WssePreset($document))
->querySingle('/wssoap:Envelope/wssoap:Header/wswsse:Security')
);
}
}
Full Changelog: https://github.com/veewee/xml/compare/v1.4.0...1.5.0
Improve decoding and encoding falsy values by @veewee and @bastien-phi in https://github.com/veewee/xml/pull/29
Full Changelog: https://github.com/veewee/xml/compare/v1.3.0...v1.4.0
Remove namespaces traverser visitor by @veewee in https://github.com/veewee/xml/pull/26
Use-case of above 2 features: You want to search for some data in SOAP, but decode it as an array afterwards - without any namespace info or prefix:
use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Dom\Traverser\Visitor\RemoveNamespaces;
use function VeeWee\Xml\Dom\Configurator\traverse;
use function VeeWee\Xml\Encoding\element_decode;
$doc = Document::fromXmlString(<<<EOXML
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>
EOXML
);
$method = $doc->xpath()->querySingle('//soap:Body')->firstElementChild;
var_dump(element_decode($method, traverse(new RemoveNamespaces())));
array(1) {
'GetStockPrice' =>
array(1) {
'StockName' =>
string(3) "IBM"
}
}
Full Changelog: https://github.com/veewee/xml/compare/v1.2.0...v1.3.0
Introduce copy_named_xmlns_attributes by @veewee in https://github.com/veewee/xml/pull/24
Full Changelog: https://github.com/veewee/xml/compare/v1.1.1...v1.2.0
Optimize duplicate namespaces on root by @veewee in https://github.com/veewee/xml/pull/23
Full Changelog: https://github.com/veewee/xml/compare/v1.1.0...v1.1.1
Add PHP 81 support by @veewee in https://github.com/veewee/xml/pull/22
Full Changelog: https://github.com/veewee/xml/compare/v1.0.1...v1.1.0
21: Fix broken root xmlns renaming
Total issues resolved: 1
Same as previous, but with a BC promise!
Same as previous, but with a BC promise!
20: Add root namespace uri locator
Total issues resolved: 1
14: Upgrade to GitHub-native Dependabot thanks to @dependabot-preview[bot]
Total issues resolved: 6
Some highlights:
comparable() configurator
use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Configurator\comparable;
use function VeeWee\Xml\Dom\Locator\document_element;
use function VeeWee\Xml\Dom\Mapper\xml_string;
$raw = <<<EOXML
<foo version="1.9" target="universe">
<item
a:sku="xml"
z:id="3"
xmlns:a="http://a"
xmlns:z="http://z"
>XML</item>
</foo>
EOXML;
$expected = <<<EOXML
<foo xmlns:ns1="http://z" xmlns:ns2="http://a" target="universe" version="1.9">
<item ns1:id="3" ns2:sku="xml">XML</item>
</foo>
EOXML;
$actualDoc = Document::fromXmlString($raw, comparable());
$actual = $actualDoc->map(static fn (DOMDOcument $doc) => xml_string()($doc->documentElement));
assert($actual === $expected);
xmlns
xmlns_attributes_list($element)
->filter(
static fn (DOMNameSpaceNode $xmlns): bool => (bool) $xmlns->prefix
)
->forEach(
static function (DOMNameSpaceNode $xmlns) use ($element) {
remove_namespace($xmlns, $element);
}
);
renaming
use function VeeWee\Xml\Dom\Manipulator\Attribute\rename as rename_attribute;
use function VeeWee\Xml\Dom\Manipulator\Element\rename as rename_element;
use function VeeWee\Xml\Dom\Manipulator\Xmlns\rename as rename_xmlns;
rename_attribute($attr, 'foo', $newUri);
rename_element($element, 'foo', $newUri);
rename_xmlns($doc, 'http://namespace', 'prefix');
8: Add replace by external nodes dom manipulator
Total issues resolved: 5
Some highlights:
Node Collections
$total = $xml->locate(elements_with_tagname('products'))
->children()
->filter(
static fn(DOMElement $element)
=> $element->getAttribute('active') === 'yes'
)
->query('./price')
->reduce(
static fn(int $total, DOMElement $price)
=> $total + value($price, Type\int()),
0
);
Traversable node visitors
$doc = Document::fromXmlFile(
$file,
traverse(
new WazzupVisitor(),
)
);
class WazzupVisitor extends AbstractVisitor
{
public function onNodeLeave(DOMNode $node) : Action
{
if (!is_attribute($node)) {
return new Action\Noop();
}
attribute($node->nodeName, 'WAZZUP')($node->parentNode);
return new Action\Noop();
}
}
```php $doc = document_encode(['hello' => 'world'], utf8(), pretty_print());
Total issues resolved: 1
$doc = document_encode(['hello' => 'world'], utf8(), pretty_print());
$out = $doc->map(xslt_template($xslt));
5: Introduce the Encoding component
Total issues resolved: 1
$data = xml_decode(
file_get_contents('file.xml'),
validator(xsd_validator('some-schema.xsd'))
);
// You can read or change the data
$data['root']['name'] = 'MyName';
// And finally convert it back to XML!
$xml = xml_encode($data, utf8(), pretty_print());
 - Improved PSL typehinting
`php $writer = Writer::forFile($someFile, indentation(' ')); $writer->write( document('1.0', 'UTF-8', element('hello', children([ attribute('default',
Total issues resolved: 1
$writer = Writer::forFile($someFile, indentation(' '));
$writer->write(
document('1.0', 'UTF-8',
element('hello', children([
attribute('default', 'world'),
element('item', value('Jos')),
element('item', value('Bos')),
element('item', value('Mos')),
]))
)
);
1: Small grammar fixes thanks to @BrentRobert
Special thanks to:
One column per quarter.