Skip to content

Instantly share code, notes, and snippets.

View pelusium's full-sized avatar

Mauro Gama pelusium

View GitHub Profile
@pelusium
pelusium / parse-xml.php
Created February 1, 2018 21:48 — forked from stojg/parse-xml.php
Parsing a huge XML with closure in PHP
<?php
// Open the XML
$handle = fopen('file.xml', 'r');
// Get the nodestring incrementally from the xml file by defining a callback
// In this case using a anon function.
nodeStringFromXMLFile($handle, '<item>', '</item>', function($nodeText){
// Transform the XMLString into an array and
print_r(getArrayFromXMLString($nodeText));