1. Go to this page and download the library: Download ottosmops/xmltoolkit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ottosmops / xmltoolkit example snippets
use Ottosmops\Xmltoolkit;
$xml = new Xmltoolkit();
$xml->loadFromFile('example.xml');
$xml->renameTagByXPath('//a', 'ref');
$xml->saveToFile('example.xml', true); // pretty print
// Find elements by attribute value
$elements = $xml->findElementsByAttributeValue('type', 'special');
// Replace attribute value
$xml->replaceAttributeValue('type', 'special', 'normal');
// Find elements by text content
$elements = $xml->findElementsByTextContent('oldtext');
// Replace text content
$xml->replaceElementTextContent('oldtext', 'newtext');
// Save as pretty-printed string
$prettyXml = $xml->saveToString(true);