All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
如何制作圆角表格_[Html教程]
动态网页制作PHP之看实例学正则表达式_php资料_编程技术
ASP.NET通过IE直接打印_[Asp.Net教程]
PHP技巧:通过实例深入剖析require和include的用法_php资料_编程技术
ASP.NET入门随想之检票的老太太_[Asp.Net教程]
php和explode_php资料_编程技术
C#中事件的概念以及以及事件实例
详细讲解动态网页制作技术PHP中的函数应用_[PHP教程]
sql_设置权限_数据库基础_mssql学习_编程技术
asp.net初学者:petshop4.0设计说明_.net资料_编程技术
Reading number is top 10 pictures
Exquisite decoration is not paying too much3
Summer is most suitable for young people to travel in China2
The beginning and end
Parking technology is great, that give you the keys can't stolen
我国房地产真相
8090后结婚的各种XX事
NeedWallpaper7
The money of more than 100 countries and regions11
From China fortress sora aoi5
The money of more than 100 countries and regions2
Download software ranking
小黑猫大战两米大花蛇
Tram sex maniac 2 (H) rar bag3
C#编程思想
C++教程第四版
终极变速大师Speeder3.26
Boxer's Top ten classic battle10
Proficient in JavaScript
Unix video tutorial7
美女写真3
Photoshop 8.0图象编辑软件
aaa published in(发表于) 2013/12/21 22:25:54 Edit(编辑)
PHP将将,XML,映射为,HTML的代码实例_php资料_编程技术

PHP将将,XML,映射为,HTML的代码实例_php资料_编程技术

PHP将将 XML 映射为 HTML的代码实例_php资料_编程技术-你的首页-uuhomepage.com

  以下范例将 XML 文档中的标记符直接映射成 HTML 标记符。在“映射数组”中不存在的元素将被忽略。当然,该范例将只对一个特定的 XML 文档有效。


$file = "data.xml";
$map_array = array(
"BOLD" => "B",
"EMPHASIS" => "I",
"LITERAL" => "TT"
);

function startElement($parser, $name, $attrs) {
global $map_array;
if ($htmltag == $map_array[$name]) {
print "<$htmltag>";
}
}

function endElement($parser, $name) {
global $map_array;
if ($htmltag == $map_array[$name]) {
print "";
}
}

function characterData($parser, $data) {
print $data;
}

$xml_parser = xml_parser_create();
// 使用大小写折叠来保证我们能在元素数组中找到这些元素名称
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}

while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
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);
?>




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.