|
![](icon/private_name/1.gif) |
13³â Àü |
<html>
<head>
<title>SAX Demonstration</title>
<META HTTP-EQUIV='Content-type' CONTENT='text/html; charset=euc-kr'>
</head>
<body>
<h1>RSS ¸®´õ±â</h1>
<?php
$file = "http://blog.naver.com/post/postXMLList.jsp?blogId=selnip";
$currentTag = "";
$currentAttribs = "";
function startElement($parser, $name, $attribs)
{
global $currentTag, $currentAttribs;
$currentTag = $name;
$currentAttribs = $attribs;
switch ($name) {
default:
echo("startElement : $name<br>");
break;
}
}
function endElement($parser, $name)
{
global $currentTag;
switch ($name) {
default:
echo("<br>$name endElement<br>");
break;
}
$currentTag = "";
$currentAttribs = "";
}
function characterData($parser, $data)
{
global $currentTag;
switch ($currentTag) {
case "link":
echo("<a href="$data">$data</a>n");
break;
case "title":
echo("title : $data");
break;
default:
echo($data);
break;
}
}
$xmlParser = xml_parser_create();
$caseFold = xml_parser_get_option($xmlParser,
XML_OPTION_CASE_FOLDING);
$targetEncoding = xml_parser_get_option($xmlParser,
XML_OPTION_TARGET_ENCODING);
if ($caseFold == 1) {
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, false);
}
xml_set_element_handler($xmlParser, "startElement", "endElement");
xml_set_character_data_handler($xmlParser, "characterData");
if (!($fp = fopen($file, "r"))) {
die("Cannot open XML data file: $file");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xmlParser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xmlParser)),
xml_get_current_line_number($xmlParser)));
xml_parser_free($xmlParser);
}
}
xml_parser_free($xmlParser);
?>
</table>
</body>
</html> |
|
̵̧ : 244 |
̵̧
¸ñ·Ï
|
|