Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

How to convert DOMDocument to XMLReader

$
0
0

I need to import a large XML file into my DB (2Gb)
I tried to use DOMDocument and it failed cause of size and read up and understand that I should rather use XMLReader.

Google search do not help much to give me an indication what I should different to read the document with XMLReader...

Can anybody please help me to either point me in the right direction to fix this document I created or even help me to rewrite the parser... I just cannot get my head arounf this problem... :confused:  :
My DOMDocument is as follow:

 

#!/usr/bin/php –q
<?
error_reporting(E_ALL);
ini_set('display_errors', '1');
$l = mysql_connect  ( XXXXX);
$total='0';
    $xml = "http://xxxxxxxxxxxxxxxxxxxx";
    $doc = new DOMDocument();
    $doc->load( $xml);
    ## lets read the code block
    $records = $doc->getElementsByTagName( "Property" );
    foreach( $records as $result )    {

    $adnr = $result->getElementsByTagName( "ID" );          // adnr
    $adnr = $adnr->item(0)->nodeValue;
    $town = $town->getElementsByTagName( "town" );          // town
    $town = $town->item(0)->nodeValue;
//////////////////////////////////////////////////////////////////////////////// Add Pics
    $pic1= $result->getElementsByTagName( "image" );
    $pic1 = $pic1->item('1')->nodeValue;
    $pic2= $result->getElementsByTagName( "image" );
    $pic2 = $pic2->item('2')->nodeValue;
    $pic3= $result->getElementsByTagName( "image" );
    $pic3 = $pic3->item('3')->nodeValue;

}
?>

Viewing all articles
Browse latest Browse all 13200

Trending Articles