Fix program to parse large XML files
Budget: $10 – $30 USD
I need to be able to parse large xml files in my api. My current process bombs if the file is over 40 meg.
I see references to DOM object and simplexml in the code - I can't manually split files before running conversions. Need to do it at a button press. Below is a portion of the code. The code works fine for smaller than 40m. Can it be changed to Stax or another parser that works with larger files.
$csv_handler = fopen ('downloads_convert/' . basename($filename, ".".$ext) . "_converted.csv", 'w');
$l = 1 ;
foreach($rline as $rlineech)
{
$domObject = new DOMDocument();
$domObject->loadXML($rlineech);
$domXPATH = new DOMXPath($domObject);
$sresults = $domXPATH->query("//soap/*");
// print_r($sresults);
foreach($sresults as $result)
{
$sarray = json_decode(json_encode(simplexml_load_string($result->ownerDocument->saveXML($result))), true);
I see references to DOM object and simplexml in the code - I can't manually split files before running conversions. Need to do it at a button press. Below is a portion of the code. The code works fine for smaller than 40m. Can it be changed to Stax or another parser that works with larger files.
$csv_handler = fopen ('downloads_convert/' . basename($filename, ".".$ext) . "_converted.csv", 'w');
$l = 1 ;
foreach($rline as $rlineech)
{
$domObject = new DOMDocument();
$domObject->loadXML($rlineech);
$domXPATH = new DOMXPath($domObject);
$sresults = $domXPATH->query("//soap/*");
// print_r($sresults);
foreach($sresults as $result)
{
$sarray = json_decode(json_encode(simplexml_load_string($result->ownerDocument->saveXML($result))), true);
Related categories:
PHP
Business, Accounting, Human Resources & Legal
XML
Software Architecture
JSON