phpnewby1918 Posted April 24, 2010 Share Posted April 24, 2010 Hi, I'm trying to broaden my scope with RSS feeds. Basically I want to be able to pull data from an RSS feed from either somewhere big like BBC or even a friends site but then be able to input this data into a mysql database. I do know there is a program RSS2MYSQL (I think) But i'd like to learn the script behind it. If i take the this script from w3schools shown below: XML FILE: <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> And then use this code to echo the data out (Shown below): <?php $xml = simplexml_load_file("test.xml"); echo $xml->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; } ?> Obviosuly this works great but i'm then unsure how i'd be able to add this data into my database. Could anybody help me out with how i'd go about doing this please? Thanks Link to comment https://forums.phpfreaks.com/topic/199573-rss-into-a-mysql-database/ Share on other sites More sharing options...
khr2003 Posted April 26, 2010 Share Posted April 26, 2010 hello basically what "simplexml_load_file" converts any well-formed XML file to an object. Onc it is converted you can use all the methods in the SimpleXMLElement class. getName() and children() are functions within this class. To understand more about this topics see these links: simplexml_load_file The SimpleXMLElement class It is always a good idea to check the php manual beforhand. hope this helps Link to comment https://forums.phpfreaks.com/topic/199573-rss-into-a-mysql-database/#findComment-1048952 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.