Web Analytics Made Easy -
StatCounter using Perl to process XML files? - CodingForum

Announcement

Collapse
No announcement yet.

using Perl to process XML files?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • using Perl to process XML files?

    Hi all,

    i have been learning php for a while now and have been using it to add xml(datafeeds) to my sql database to create a price comparision function on my website.

    however i have run into a few problems with php
    the larger feeds over 4000 items caused errors relating to 30 second timeout. and only the items read in that time were added to the database

    so i asked mlseim if a CRON job would rid those problems but the answer was no so he suggested that i come here and ask about the limitations of pearl and if it would be better to use perl instead of php.

    here is my php code
    PHP Code:
     $xml=("http://www.kernow-connect.com/feeds/bench.xml");


    $xmlDoc = new DOMDocument();
    $xmlDoc->load($xml);
    $channels=$xmlDoc->getElementsByTagName('prod'); 

    $merchant $xmlDoc->getElementsByTagName('merchant')->item(0);
    $merchant_name $merchant->getAttribute('name');
    print 
    $merchant_name;

    for (
    $i 0$i <  $channels->length$i++) { 
    $channel $channels->item($i);//get elements from "<channel>"

    $channel_title 
    mysql_real_escape_string($channel->getElementsByTagName('name')->item(0)->childNodes->item(0)->nodeValue);

    $channel_image 
    mysql_real_escape_string($channel->getElementsByTagName('mImage')->item(0)->childNodes->item(0)->nodeValue);

    $channel_link 
    mysql_real_escape_string($channel->getElementsByTagName('awTrack')->item(0)->childNodes->item(0)->nodeValue);

    $channel_desc 
    mysql_real_escape_string($channel->getElementsByTagName('desc')->item(0)->childNodes->item(0)->nodeValue);

    $channel_promo 
    mysql_real_escape_string($channel->getElementsByTagName('promo')->item(0)->childNodes->item(0)->nodeValue);

    $channel_id 
    mysql_real_escape_string($channel->getElementsByTagName('pId')->item(0)->childNodes->item(0)->nodeValue);

    $channel_cost 
    mysql_real_escape_string($channel->getElementsByTagName('buynow')->item(0)->childNodes->item(0)->nodeValue);

    $sql "INSERT INTO product_database (pID, store, storeLink, productTitle, productLink, productIMG, description, price) VALUES ($channel_id, '$merchant_name', '$channel_link', '$channel_title', '$channel_link', '$channel_image', '$channel_desc','$channel_cost')";
    $query mysql_query($sql);


    any help would be appreciated
    p.s unfortunatly i know nothing of perl so please bear with me

    cheers
    Luke
    Last edited by LJackson; Apr 10, 2009, 04:13 PM.
Working...
X