Updated: 12 November 2026 · Applies to: PHP 8.4 on Debian 13, PHP 8.3 on AlmaLinux 10, the official php:8.3-cli Docker image, cPanel servers

PHP handles XML through six extensions: libxml (the base library), xml (the event-based XML Parser), dom, SimpleXML, XMLReader and XMLWriter. XSLT transformations need one more, xsl, which gives you the XSLTProcessor class. To see which of them your PHP has, run:

php -m | grep -iE '^(libxml|xml|dom|simplexml|xmlreader|xmlwriter|xsl)$'

On a server with everything installed the output is:

dom
libxml
SimpleXML
xml
xmlreader
xmlwriter
xsl

If a name is missing, install the package for your system below. On shared hosting, check a phpinfo() page instead, because the command line PHP can differ from the PHP your website uses.

What each module is for

  • dom: loads a whole XML or HTML document into a tree (DOMDocument) that you can read, change and save.
  • SimpleXML: the easiest way to read small XML files, for example simplexml_load_file().
  • XMLReader and XMLWriter: read or write XML as a stream, node by node, so large files do not have to fit in memory.
  • xml: the older event-based parser (xml_parser_create()).
  • xsl: applies an XSLT 1.0 stylesheet to a DOM document with XSLTProcessor. It is built on the libxslt library.

Install the XML and XSL extensions

Debian and Ubuntu. The php-xml package holds all of them, xsl included. We tested on Debian 13, where php-cli alone had only libxml:

apt install php-xml

It installs php8.4-xml on Debian 13 and enables each module with its own file in /etc/php/8.4/*/conf.d/ (15-xml.ini, 20-dom.ini, 20-simplexml.ini, 20-xmlreader.ini, 20-xmlwriter.ini, 20-xsl.ini). Restart PHP-FPM or Apache afterwards so the website picks it up, for example:

systemctl restart php8.4-fpm

AlmaLinux, Rocky Linux and RHEL. Here too one package, php-xml, provides dom, SimpleXML, xml, XMLReader, XMLWriter and xsl (tested on AlmaLinux 10 with PHP 8.3):

dnf install php-xml

The module files go to /etc/php.d/. Restart php-fpm or httpd afterwards.

Docker (official php image). The php:8.3-cli image already includes dom, SimpleXML, xml, XMLReader and XMLWriter, but not xsl. Add it in your Dockerfile:

apt-get update && apt-get install -y libxslt1-dev && docker-php-ext-install xsl

cPanel servers. On a VPS or dedicated server with WHM, add the extension for your PHP version in WHM › Software › EasyApache 4: click Customize on the current profile, go to the PHP extensions step, search for xsl (or xml), select it, then Review and Provision, according to cPanel. Our guide How to Install PHP extensions on cPanel server? has more detail. On shared hosting, use Software › Select PHP Version if your cPanel shows it, or open a ticket and ask support to enable the extension for your account.

Test it with a small XSLT transformation

Save this as books.xml:

<?xml version="1.0"?>
<books><book><title>Linux Basics</title><price>10</price></book><book><title>PHP Guide</title><price>15</price></book></books>

Save this stylesheet as books.xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
  <xsl:template match="/">
    <ul><xsl:for-each select="books/book"><li><xsl:value-of select="title"/></li></xsl:for-each></ul>
  </xsl:template>
</xsl:stylesheet>

And this as t.php:

<?php
$xml = new DOMDocument();
$xml->load(__DIR__ . '/books.xml');
$xsl = new DOMDocument();
$xsl->load(__DIR__ . '/books.xsl');
$proc = new XSLTProcessor();
$proc->importStylesheet($xsl);
echo $proc->transformToXML($xml);

Run it:

php t.php

Output:

<ul>
<li>Linux Basics</li>
<li>PHP Guide</li>
</ul>

SimpleXML reads the same file in three lines:

<?php
$books = simplexml_load_file(__DIR__ . '/books.xml');
foreach ($books->book as $b) {
    echo $b->title, ': ', $b->price, PHP_EOL;
}

Output:

Linux Basics: 10
PHP Guide: 15

Errors that mean a module is missing

  • Class "XSLTProcessor" not found: the xsl extension is not loaded. We got exactly this after turning off only xsl on Debian 13: PHP Fatal error: Uncaught Error: Class "XSLTProcessor" not found in /t/t.php:6.
  • Class "DOMDocument" not found: the dom extension (on Debian and AlmaLinux, the whole php-xml package) is missing.
  • Call to undefined function simplexml_load_file(): SimpleXML is missing.

For details of the libraries PHP was built against, run php --ri xsl. On Debian 13 it reported libxslt 1.1.35 and libxml 2.9.14.

Official documentation: PHP XSL, PHP DOM, cPanel EasyApache 4.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

Server management

on-demand administration, hardening, migrations and monitoring.

Was this answer helpful?

Still stuck? Open a ticket