1. Go to this page and download the library: Download phpcfdi/cfdi-cleaner 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/ */
phpcfdi / cfdi-cleaner example snippets
use PhpCfdi\CfdiCleaner\Cleaner;
$xml = file_get_contents('cfdi.xml');
echo Cleaner::staticClean($xml);
use PhpCfdi\CfdiCleaner\Cleaner;
$xml = file_get_contents('cfdi.xml');
$cleaner = new Cleaner();
echo $cleaner->cleanStringToString($xml);
use PhpCfdi\CfdiCleaner\Cleaner;
$xml = file_get_contents('cfdi.xml');
$cleaner = new Cleaner();
$document = $cleaner->cleanStringToDocument($xml);
echo $document->saveXML();
use PhpCfdi\CfdiCleaner\Cleaner;
use PhpCfdi\CfdiCleaner\ExcludeList;
use PhpCfdi\CfdiCleaner\XmlDocumentCleaners\RemoveAddenda,
use PhpCfdi\CfdiCleaner\XmlDocumentCleaners\RemoveNonSatNamespacesNodes,
use PhpCfdi\CfdiCleaner\XmlDocumentCleaners\RemoveNonSatSchemaLocations,
/**
* @var string $contents El contenido XML sucio.
*/
$exclude = new ExcludeList(
RemoveAddenda::class,
RemoveNonSatNamespacesNodes::class,
RemoveNonSatSchemaLocations::class,
);
$cleaner = new Cleaner();
$cleaner->exclude($exclude);
$contents = $cleaner->cleanStringToString($contents);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.