PHPackages                             wp-php-toolkit/xml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. wp-php-toolkit/xml

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

wp-php-toolkit/xml
==================

XML component for WordPress.

v0.8.1(1mo ago)0120.1k↑100260%2GPL-2.0-or-laterPHPPHP &gt;=7.2

Since Jun 2Pushed 1mo agoCompare

[ Source](https://github.com/wp-php-toolkit/xml)[ Packagist](https://packagist.org/packages/wp-php-toolkit/xml)[ Docs](https://wordpress.github.io/php-toolkit/reference/xml.html)[ RSS](/packages/wp-php-toolkit-xml/feed)WikiDiscussions trunk Synced yesterday

READMEChangelogDependencies (6)Versions (49)Used By (2)

   slug xml   title XML   install wp-php-toolkit/xml   see\_also    dataliberation | DataLiberation | Read and write WXR-sized WordPress exports as entities.

 encoding | Encoding | Validate and scrub text before strict XML processing.

 bytestream | ByteStream | Keep large XML reads incremental.

    A streaming, namespace-aware XML processor in pure PHP. Read and modify huge feeds, WXR exports, ePub manifests, and Office Open XML parts without ever loading the document into memory and without depending on `libxml2`.

When the native API extension is loaded, `XMLProcessor` can use a native delegate by default while preserving PHP fallback behavior. Define `WP_NATIVE_APIS_DISABLE_DEFAULTS` before loading the component to force the pure PHP fallback.

Why this exists
---------------

[](#why-this-exists)

`SimpleXMLElement` and `DOMDocument` both need `libxml2` and both build a complete in-memory tree. `XMLProcessor` walks the document forward as a cursor, keeps modifications in a side buffer, and emits the full updated XML with `get_updated_xml()` only when you ask for it.

This design came from WordPress-scale documents such as WXR exports. A migration may only need to rewrite `wp:attachment_url` values or bump a feed attribute, so the processor optimizes for targeted cursor edits instead of a full validating XML stack.

Footgun: **Namespace-aware methods use the namespace URI, not the prefix written in the tag.** In WXR, `get_attribute( 'wp', 'status' )` looks for a namespace literally named `wp`; for the usual WXR declaration you want `get_attribute( 'http://wordpress.org/export/1.2/', 'status' )`.

Footgun: **In streaming mode `next_tag()` can return false because input ran out, not because the document ended.** Check `is_paused_at_incomplete_input()` before assuming you're done.

Bump every price in a catalog
-----------------------------

[](#bump-every-price-in-a-catalog)

Find each ``, read its price, write a new one, emit the updated document.

```
