webnsk
Сообщений: 35
Оценки: 0
Присоединился: 2007-12-03 07:37:56.713333
|
Вот это полноценны парсер на пхп пользуйтесь каму нужно )))) я уже пользуюсь quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>Новости</title></head> <body> <? $tag = $title = $link = $pubDate = $description = ''; function processRSSItem($title, $link, $time, $description) { echo "<div style=\"width: 600px; background-color: #e0e0e0;\">" . strftime("%e.%m.%Y %H:%M", $time) . "<br>\n"; echo "<b>$title</b></a></div>\n"; echo "<p style=\"width: 600px; text-indent: 20px; text-align: justify; \">$description "; echo "<a href=\"$link\">Подробности…</a></p>\n"; } function tagOpen($parser, $tagName, $attributes = NULL) { global $tag, $title, $link, $pubDate, $description; if (($tag = $tagName) == "ITEM") $title = $link = $pubDate = $description = ''; } function tagClose($parser, $tagName) { global $tag, $title, $link, $pubDate, $description; $tag = ''; if (($tagName == "ITEM") && ($title != '') && (link != '') && ($pubDate != '') && ($description != '')) processRSSItem($title, $link, strtotime($pubDate), $description); } function tagContent($parser, $content) { global $tag, $title, $link, $pubDate, $description; switch ($tag) { case "TITLE": $title .= $content; break; case "LINK": $link .= $content; break; case "PUBDATE": $pubDate .= $content; break; case "DESCRIPTION": $description .= $content; break; } } $RSSParser = xml_parser_create(); xml_set_element_handler($RSSParser, "tagOpen", "tagClose"); xml_set_character_data_handler($RSSParser, "tagContent"); if ($fp = fopen("http://www.ixbt.com/export/dvdnews.rss", "r")) { while ($data = fread($fp, 4096)) { flush(); if (!xml_parse($RSSParser, $data, feof($fp))) die(sprintf("Ошибка XML: %s в строке %d", xml_error_string(xml_get_error_code($rss_parser)), xml_get_current_line_number($rss_parser))); } fclose($fp); } xml_parser_free($RSSParser); ?> </body></html>
|