PHP code example of sandcore-dev / xml-analyzer

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

    

sandcore-dev / xml-analyzer example snippets


$analyzer = new \SandcoreDev\XmlAnalyzer\XmlAnalyzer();

// Analyze one or more XML strings. More data is more accurate. 
$result = $analyzer->process($xmlString, $anotherXmlString, ...$moreXmlStrings);

// Analyze one or more XML files. More data is more accurate.
$result = $analyzer->processFile($xmlFile, $anotherXmlFile, ...$moreXmlFiles);

// Available types are in src/Types/
$result->getType();

$result->getAttributes();
$result->getAttribute('foo');

$result->getChildren();
$child = $result->getChild('bar');

// Each (child) node has the same methods available
$child->getType();
$child->getAttributes();
$child->getChildren();