This is an easy way to convert RSS data to an array so that it is easy to access that data and do stuff with it, enjoy:
PHP Code:
function parse_rss($data) {
$data = iconv('UTF-8', 'UTF-8//IGNORE', $data); // Remove invalid characters
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
if (!xml_parse_into_struct($xml_parser, $data, $vals, $index)) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
return $vals;
}
Bookmarks