Parsing a file with 66k lines


#1

I have an XML file with 66k+ lines. When I attempt to parse it and open the preview into chrome I get “502 Bad Gateway”. If I take about 700 of the lines in a separate XML file it will parse and display correctly. What am I missing here? Any help would be greatly appreciated!

Thanks,
Matt


#2

The error doesn’t sound correct.

Do you need the entire file or just portions of it?


#3

I need the entire file. I just used part of it to see how much I could get a browser to display without the 502 Bad Gateway error


#4

This is what I am using to parse the data

[php]
class permit_data_parser
{
function get_permit_data_from_xml($filename){
if (file_exists($filename)){
$result = simplexml_load_file($filename);
return $this->parse_raw_xml_permit_data($result);
}
return ‘File not found’;
}

function parse_raw_xml_permit_data($xml){
$results = ‘’;
foreach($xml->Body->Table->Records->Record as $record)
{
$results = $results.‘Record’.""\n";
foreach($record->attributes() as $name => $value) {
$results = $results . $name . ‘="’ . $value . “”\n";
}
// $results = $results.‘Pests’.""\n";
// foreach($xml->Body->Table->Records->Record->PESTS->PEST as $pest)
// {
// foreach($pest->attributes() as $name => $value) {
// $results = $results . $name . ‘="’ . $value . “”\n";
// }
// }
$results = $results.‘Sites’.""\n";
foreach($xml->Body->Table->Records->Record->SITES->SITE as $site)
{
foreach($site->attributes() as $name => $value) {
$results = $results . $name . ‘="’ . $value . “”\n";
}
}
$results = $results.‘Site Pests’.""\n";
foreach($xml->Body->Table->Records->Record->SITES->SITE->SITEPESTS->SITEPEST as $sitepest)
{
foreach($sitepest->attributes() as $name => $value) {
$results = $results . $name . ‘="’ . $value . “”\n";
}
}
}
return $results;
}
[/php]


#5