function fetch_xml($url) { $xml_string =& fetch_file_via_socket($url); if ($xml_string === false or empty($xml_string['body'])) { // error returned if (VB_AREA == 'AdminCP') { trigger_error('Unable to fetch RSS Feed', E_USER_WARNING); } } $xml_string = $xml_string['body']; // There are some RSS feeds that embed (HTML) tags within the description without // CDATA. While this is actually invalid, try to workaround it by wrapping the // contents in CDATA if it contains a < and is not in CDATA already. // This must be done before parsing because our parser can't handle the output. if (preg_match_all('#(<description>)(.*)(</description>)#siU', $xml_string, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { if (strpos(strtoupper($match[2]), '<![CDATA[') === false and strpos($match[2], '<') !== false) { // no CDATA tag, but we have an HTML tag $output = $match[1] . '<![CDATA[' . vB_XML_Builder::escape_cdata($match[2]) . ']]>' . $match[3]; $xml_string = str_replace($match[0], $output, $xml_string); } } } $this->set_xml_string($xml_string); return true; }