Download the PHP package wp-php-toolkit/xml without Composer
On this page you can find all versions of the php package wp-php-toolkit/xml. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wp-php-toolkit/xml
More information about wp-php-toolkit/xml
Files in wp-php-toolkit/xml
Package xml
Short Description XML component for WordPress.
License GPL-2.0-or-later
Homepage https://wordpress.github.io/php-toolkit/reference/xml.html
Informations about the package xml
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 huge feeds, WXR exports, ePub manifests, and Office Open XML parts incrementally, then emit edited XML without depending on libxml2.
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. Reading stays incremental; materializing the updated XML still allocates the resulting document.
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
Find each <book>, read its price, write a new one, emit the updated document.
Read namespaced attributes from a WXR export
WordPress's WXR commonly uses wp:, dc:, and content: prefixes bound to namespace names such as http://wordpress.org/export/1.2/. Pass that expanded namespace name, not the prefix; the processor handles whichever prefix the document actually uses.
Rewrite URLs across an entire WXR export
Large WXR exports can hold many URLs in <link>, <guid>, and post content. The cursor can find and rewrite matching text nodes incrementally; calling get_updated_xml() returns the complete rewritten document.
Parse OPML to extract feed URLs
OPML is the format Feedly and many readers use to import/export feed lists. Flat, attribute-heavy XML — exactly what a tag processor handles best.