PHP code example of horat1us / simple-xml

1. Go to this page and download the library: Download horat1us/simple-xml 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/ */

    

horat1us / simple-xml example snippets




use Horat1us\SimpleXML;

$path = 'valid.xml';

try {
    $element = SimpleXML\Parse::file($path/*, $className*/);    
} catch(SimpleXML\Parse\Exception\InvalidFilePath $e) {
    $path = $e->getPath();
} catch(SimpleXML\Parse\Exception\InvalidFormat\File $e) {
    $filePath = $e->getPath();
    $libXmlErrors = $e->getErrors();
} catch(SimpleXML\Parse\Exception\InvalidClassName $e) {
    $className = $e->getClassName();
}



use Horat1us\SimpleXML;

$path = 'valid.xml';

try {
    $element = SimpleXML\Parse::file($path/*, $className*/);    
} catch(SimpleXML\Parse\Exception\InvalidFormat\Data $e) {
    $contents = $e->getContents();
    $libXmlErrors = $e->getErrors();
} catch(SimpleXML\Parse\Exception\InvalidClassName $e) {
    $className = $e->getClassName();
}