ֲͲ ò ² Ͳֲ

[ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ]
[ 16 ] [ 17 ] [ 18 ] [ 19 ] [ 20 ] [ 21 ] [ 22 ] [ 23 ] [ 24 ] [ 25 ] [ 26 ] [ 27 ] [ 28 ] [ 29 ] [ 30 ] [ 31 ] [ 32 ]
[ 33 ] [ 34 ] [ 35 ] [ 36 ] [ 37 ] [ 38 ] [ 39 ] [ 40 ] [ 41 ] [ 42 ] [ 43 ] [ 44 ] [ 45 ] [ 46 ] [ 47 ] [ 48 ] [ 49 ] [ 50 ]

 

, , RSS-.
. 5.4.
5.4
RSS- PRIM.RSS


<?xml version=1.0 encoding=windows-1251?>

<rss version=2.0>

<channel>

<title>Avia-virtl.</title>

<link>HTPP://localhost/</link>

<description> </description>

<image>

<url>HTPP://localhost/img/avia.gif</url>

<title>Avia-virtl.</title>

<link>HTPP://localhost/</link>

</image>

<item>

<title> RSS-</title>

<link>HTPP://localhost/news/188000.html</link>

<pubDate>Thu, 17 Mar 2005 23:10:13 +0200</pubDate>

<description> RSS- </description>

</item>

<item>

<title> Nashi Avia 50 %</title>

<link>HTPP://localhost/news/188001.html</link>

<pubDate>Thu, 17 Mar 2005 23:15:24 +0200</pubDate>

<description> Nashi Avia 50 % . </description>

</item>

</channel>

</rss>

RSS- -.
ϳ , .xml .rss. prim.rss.
ϳ Web- , localhost ( .html ).
, RSS- , HTML- ( ). RSS- (. 5.1), . , , .

. 5.1. RSS-
:
Daypop: HTPP://.daypop./info/submit.htm;
Syndic8: HTPP://.syndic8./suggest.php?Mode=data;
Edu_RSS: HTPP://.downes.ca/cgi-bin/xml/feeds.cgi .
2. RSS- HTML-.
prim.rss , ົ .
, , , .html-.
RSS- - (), [32], . 5.5.
5.5
˲ RSS-


<?php

/* */

class RSSParser {

// , te,

// <item> false,

var $insideitem = false;

//

var $tag = ;

// ,

// , :

// < title>, <description> and <link>

var $title = ;

var $description = ;

var $link = ;

 

//

function startElement($parser, $tagName, $attrs) {

if ($this->insideitem) {

// <item>,

// tag

$this->tag = $tagName;

} elseif ($tagName == ITEM) {

$this->insideitem = te;

. 5.5


}

}

//

function endElement($parser, $tagName) {

if ($tagName == ITEM) {

// HTML-

printf(<p><b><a href= %s> %s</a></b></p>,

trim($this->link),htmlspecialchars(trim($this->title)));

printf(<p> %s</p>,

htmlspecialchars(trim($this->description)));

// ,

$this->title = ;

$this->description = ;

$this->link = ;

$this->insideitem = false;

}

}

//

//

function characterData($parser, $data) {

if ($this->insideitem) {

switch ($this->tag) {

case TITLE:

$this->title.= $data;

break;

case DESCRIPTION:

$this->description.= $data;

break;

case LINK:

$this->link.= $data;

break;

}

}

}

}

// XML parser

$xml_parser = xml_parser_create();

$rss_parser = new RSSParser();

xml_set_object($xml_parser,&$rss_parser);

// ,

xml_set_element_handler($xml_parser, startElement, endElement);

// ,

xml_set_character_data_handler($xml_parser, characterData);

// ³ XML-

$fp = fopen(prim.rss,r)

or die(Error reading RSS data.);

// XML- 4KB

while ($data = fread($fp, 4096))

// XML-

. 5.5


xml_parse($xml_parser, $data, feof($fp))

// ³

or 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-

fclose($fp);

// ,

xml_parser_free($xml_parser);

?>

[ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ]
[ 16 ] [ 17 ] [ 18 ] [ 19 ] [ 20 ] [ 21 ] [ 22 ] [ 23 ] [ 24 ] [ 25 ] [ 26 ] [ 27 ] [ 28 ] [ 29 ] [ 30 ] [ 31 ] [ 32 ]
[ 33 ] [ 34 ] [ 35 ] [ 36 ] [ 37 ] [ 38 ] [ 39 ] [ 40 ] [ 41 ] [ 42 ] [ 43 ] [ 44 ] [ 45 ] [ 46 ] [ 47 ] [ 48 ] [ 49 ] [ 50 ]


! , . . . / , .
© 2007-2021 BPK Group.