rahulephp Posted August 18, 2010 Share Posted August 18, 2010 I am a php programmer but I am not so good with XML files. For a price comparison website, I need to parse the Amazons XML feed to store product data into the database. Can anyone please help me to find out such a simple script to parse Amazon XML product feed??? (Actually, I need each product data in array to be stored into the database) Thank you in advance. Quote Link to comment https://forums.phpfreaks.com/topic/211053-how-to-parse-xml-product-feed-using-php/ Share on other sites More sharing options...
HuggieBear Posted August 18, 2010 Share Posted August 18, 2010 I've used MagicPasrer before and it's excellent, with great support. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/211053-how-to-parse-xml-product-feed-using-php/#findComment-1100677 Share on other sites More sharing options...
grantp22 Posted August 18, 2010 Share Posted August 18, 2010 You can use it like this: <?php // $rss=simplexml_load_file("http://www.somesite.com/rss/yourtarget.xml");// can also be yourtarget.rss // foreach($rss->channel->item as $post){ //create multi-dimentional array to hold element values $myarray[0] = array( "Url" => $post->link, "Title" => $post->title, "Description" => $post->description, ); } ?> Call it as follows: echo $myarray[0]['Url']; or put into an element like this: <td><?php echo $myarray[0]['Url']; ?></td> Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/211053-how-to-parse-xml-product-feed-using-php/#findComment-1100711 Share on other sites More sharing options...
grantp22 Posted August 18, 2010 Share Posted August 18, 2010 I just noticed I forgot to add a counter: use like this: <?php // $rss=simplexml_load_file("http://www.somesite.com/rss/yourtarget.xml");// can also be yourtarget.rss // $i=0; foreach($rss->channel->item as $post){ //create multi-dimentional array to hold element values $myarray[$i] = array( "Url" => $post->link, "Title" => $post->title, "Description" => $post->description, ); $i++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/211053-how-to-parse-xml-product-feed-using-php/#findComment-1100765 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.