If WordPress, a plugin, or a CLI task throws an error about SimpleXMLElement, the XML extension is not loaded for your active PHP version. This is common after PHP upgrades.
1) Confirm the active PHP version
php -v
php -m | grep -i simplexml
If the second command returns nothing, install the XML package for your active version.
2) Install the XML module
Examples for common Ubuntu setups:
sudo apt update
sudo apt install -y php-xml
# or version-specific, e.g.
# sudo apt install -y php8.2-xml
3) Restart PHP runtime and web server
sudo systemctl restart apache2
# or if using php-fpm
# sudo systemctl restart php8.2-fpm
# sudo systemctl restart nginx
4) Validate in web context
Create a temporary test file:
<?php
var_dump(class_exists('SimpleXMLElement'));
Expected output: bool(true).
5) Common edge cases
- Multiple PHP versions installed: Apache/CLI may use different versions.
- FPM pool not restarted after package install.
- Container image missing XML module layer.
Once SimpleXMLElement is loaded in both CLI and web contexts, related plugin and update tasks should run normally.
Validation Commands
php -v
sudo systemctl status mysql
sudo tail -n 80 /var/log/mysql/error.log
Further reading: PHP Installation and Configuration
Related posts: