PHP code example of ottosmops / xmltoolkit

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

 

ttosmops\Xmltoolkit;

$xml = new Xmltoolkit();
$xml->loadFromFile('example.xml');
$xml->renameTagByXPath('//a', 'ref');
$xml->saveToFile('example.xml');


public function loadFromFile(string $filePath): bool

public function loadFromString(string $xmlString): bool

public function loadFromFragment(string $xmlFragment): bool

public function saveToFile(string $filePath): bool

public function saveToString(): string

public function renameTagByXPath(string $xpathExpression, string $newTagName): 
void

public function renameAttributeByXPath(string $xpathExpression, string $oldAttributeName, string $newAttributeName): void

public function addAttributeByXPath(string $xpathExpression, string $attributeName, string $attributeValue): void

public function removeAttributeByXPath(string $xpathExpression, string $attributeName): void

public function queryXPath(string $xpathExpression): array

public function appendHtmlToXPath(string $xpathExpression, string $htmlString): void


    public function removeElementByXPath(string $xpathExpression): void

public function wrapElementByXPath(string $xpathExpression, string $wrapperTagName): void

public function unwrapElementByXPath(string $xpathExpression): void