drizac Posted August 17, 2011 Share Posted August 17, 2011 Hello I thought I had it all figured out, but apparently not. I want to write content from an RSS feed into an HTML table. I dont want all of it in one big pile, so I tried using some tricks and regular expressions. This is a snippet from the feed: <?xml version="1.0" encoding="utf-8" ?> - <root> - <products> - <product> <categoryPath>Stuff</categoryPath> <productName>product_name_01</productName> <productCode>22-356-12/756</productCode> <eanNumber /> <manufactorSku /> <price>9999.00</price> <deliveryCost>0.00</deliveryCost> <deliveryTime>5 - 10 days</deliveryTime> <availability>In Stock</availability> <url>http://home.com/boats/fuel.aspx</url> </product> ... </products> - </root> This is my code: $html = file_get_contents('http://home.com/feed/feedfile.aspx'); preg_match_all('/<product>.+<\/product>/', $html , $strng); // Reg_ex echo "<table border=\"1\"> <tr><th>Link</th></tr>"; foreach($strng as $url) { echo "<tr><td>"; echo $url; print_r($url); echo "</td></tr>"; } I am getting this result: Link Title ArrayArray ( ) Can anyone help me identify what am I doing wrong and help me in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/244993-print-rss-feed-to-table/ Share on other sites More sharing options...
WebStyles Posted August 17, 2011 Share Posted August 17, 2011 try something like this: $html = file_get_contents('http://home.com/feed/feedfile.aspx'); preg_match_all("/\<product\>(.*?)\<\/product\>/si", $html , $strng); // Reg_ex echo "<table border=\"1\"> <tr><th>Link</th></tr>"; foreach($strng[0] as $url) { echo "<tr><td>"; echo $url; echo "</td></tr>"; } Quote Link to comment https://forums.phpfreaks.com/topic/244993-print-rss-feed-to-table/#findComment-1258574 Share on other sites More sharing options...
drizac Posted August 17, 2011 Author Share Posted August 17, 2011 Thank you very much That did it. Quote Link to comment https://forums.phpfreaks.com/topic/244993-print-rss-feed-to-table/#findComment-1258576 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.