Skip to content

Instantly share code, notes, and snippets.

View Genebi's full-sized avatar
🏠
Working from home

Alejandro Medina Genebi

🏠
Working from home
  • Genebi
  • México
  • 05:01 (UTC -06:00)
  • LinkedIn in/genebi
View GitHub Profile
@goedecke
goedecke / readcfdi.php
Created November 24, 2016 15:40
Extraer información de CFDI XML facil con simplexml
<?php
$xml = simplexml_load_file('test.xml');
$ns = $xml->getNamespaces(true);
$xml->registerXPathNamespace('c', $ns['cfdi']);
$xml->registerXPathNamespace('t', $ns['tfd']);
//EMPIEZO A LEER LA INFORMACION DEL CFDI E IMPRIMIRLA
foreach ($xml->xpath('//cfdi:Comprobante') as $cfdiComprobante){
echo $cfdiComprobante['version'];