Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The easiest way to go would be to use <code>cURL</code> to get the info as XML from the rss url, and then use <code>simplexml</code> to turn the rss XML into a traversable object. Use Xpath to get the parts of the XML you want to store in the DB. Finally, move the data to the DB.</p> <h2>Example</h2> <p>Sorry, I was rushing out the door when I saw your question. I actually wrote a really simple script a week ago to do most of what you are talking about:</p> <pre><code> //cURL to get RSS as XML function get_rss($feed_url) { $feed_request = curl_init($feed_url); curl_setopt($feed_request, CURLOPT_RETURNTRANSFER, 1); $feed_xml = curl_exec($feed_request); curl_close($feed_request); return $feed_xml; } function rss2sql($xml, $sql) { //simplexml to convert XML to objects $rss_xml = simplexml_load_string($xml); //XPath to get an array of items in RSS $rss_items = $rss_xml -&gt; xpath('//item'); if(!$rss_items) { die("No Items In RSS Feed!"); } else { //Loop through each item, convert to string, insert string to MySQL foreach($rss_items as $item) { $item_array = array($item-&gt;title,$item-&gt;link,$item-&gt;guid,$item-&gt;description); $item_sql = "(".implode(","$item_array).")"; $item_sql = $sql -&gt; escape_string($item_sql); $insert = "INSERT INTO rsstable VALUES('$item_sql'); $sql -&gt; query($insert); } } } $sql = new mysqli("localhost", "my_user", "my_password", "world"); $rss_url = "http://example.org/rssfeed"; $rss_xml = get_rss($rss_url); rss2sql($its_rss_alerts_xml, $sql); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload