请问有对php结合xml开发应用比较熟悉的吗?。。。。。 在文档中心查找“使用PHP DOM-XML创建和解析XML文件”。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?class myxml{ var $parser; function myxml() { $this->parser = xml_parser_create(); xml_set_object($this->parser,&$this); xml_set_element_handler($this->parser, "tag_on", "tag_off"); xml_set_character_data_handler($this->parser, "mycdata"); } function tag_on($parser, $tag, $attributes) { $curr_line = xml_get_current_line_number($parser); echo "<font color=red>parser=".$parser.";tag=".$tag.";attributes=".$attributes.";curr_line=".$curr_line."</font><br>"; if($curr_line==2) { echo "\n<tr>"; } else { if($curr_line!=1) { $value = ($curr_line-3)%6; echo "<font color=green>value=".$value."</font><br>"; switch((($curr_line-3)%6)) { case 0: echo "\n<tr>"; break; case 1: echo "\n<td>"; break; case 2: echo "\n<td>"; break; case 3: echo "\n<td>"; break; case 4: echo "\n<td>"; break; case 5: break; } } } } function tag_off($parser, $tag) { $curr_line = xml_get_current_line_number($parser); if($curr_line!=1 && $curr_line!=2) { switch((($curr_line-3)%6)) { case 0: break; case 1: echo "</td>"; break; case 2: echo "</td>"; break; case 3: echo "</td>"; break; case 4: echo "</td>"; break; case 5: echo "\n</tr>"; break; } } } function mycdata($parser, $cdata) { echo $cdata; } function parse($data) { xml_parse($this->parser,$data); }}$xml_parser = new myxml();$xmlfilename = "students.xml";$fp = fopen($xmlfilename, "r");$xmldata = fread($fp, filesize($xmlfilename));echo "<table border=1 width=100%>";echo "<tr>";echo "<td>id</td>";echo "<td>name</td>";echo "<td>password</td>";echo "<td>test</td>";echo "</tr>";$xml_parser->parse($xmldata);echo "</table>";?> students.xml文件如下<?xml version="1.0" encoding="GB2312" ?><USERMANAGEMENT><students><student> <id>1</id> <name>aa</name> <password>password</password> <test>test</test></student><student> <id>2</id> <name>bb</name> <password>password</password> <test>test</test></student><student> <id>3</id> <name>cc</name> <password>password</password> <test>test</test></student></students></USERMANAGEMENT> 本人觉得如果可以对浏览器作些限制(ie5以上),可以直接用xml和html结合的方法完成页面的显示,方法如下:<XML id='studentsinfo' src='aa.xml'>";</XML><table border=1 width=100% id='studentslist' datapagesize='20' datasrc='#studentsinfo'> <thead> <tr> <td>id</td> <td>name</td> <td>password</td> </tr> <tbody> <tr> <td><span datafld='id'></span></td> <td><span datafld='name'></span></td> <td><span datafld='password'></span></td> </tr> <tfoot> <tr> <td width="600" colspan="3"> <table cellpadding="0" cellspacing="0"> <tr> <td> <img src="first.gif" onclick="languagelist.firstPage()"> </td> <td> <img src="back.gif" onclick="languagelist.previousPage()"> </td> <td> <img src="next.gif" onclick="languagelist.nextPage()"> </td> <td> <img src="last.gif" onclick="languagelist.lastPage()"> </td> </tr> </table> </td> </tr></table> 求助 网上下的一个上传的类,有的jpg可以上传有的不可以,不懂为什么,跪求解答 纠结了一天的转pdf问题,还是不行 session的问题,大侠进来看看 一些PHP问题. php做类似百度搜索下拉自动提示框效果 PHP网站批量上传音乐文件的问题: PHP配置完成后,form表单不能传变量到下张页面怎么回事,高手快来帮帮忙啊!!!!!!! 救命:系统2000 server + php + mysql +iis被人黑掉之后 请问php中url编码问题 谢谢大哥关于多选框的排列? 如何挽救 MySQL 的服务!在线等待 我急!!SESSION 传递的问题??
class myxml
{
var $parser;
function myxml()
{
$this->parser = xml_parser_create();
xml_set_object($this->parser,&$this);
xml_set_element_handler($this->parser, "tag_on", "tag_off");
xml_set_character_data_handler($this->parser, "mycdata");
}
function tag_on($parser, $tag, $attributes)
{
$curr_line = xml_get_current_line_number($parser);
echo "<font color=red>parser=".$parser.";tag=".$tag.";attributes=".$attributes.";curr_line=".$curr_line."</font><br>";
if($curr_line==2)
{
echo "\n<tr>";
}
else
{
if($curr_line!=1)
{
$value = ($curr_line-3)%6;
echo "<font color=green>value=".$value."</font><br>";
switch((($curr_line-3)%6))
{
case 0:
echo "\n<tr>";
break;
case 1:
echo "\n<td>";
break;
case 2:
echo "\n<td>";
break;
case 3:
echo "\n<td>";
break;
case 4:
echo "\n<td>";
break;
case 5:
break;
}
}
}
}
function tag_off($parser, $tag)
{
$curr_line = xml_get_current_line_number($parser);
if($curr_line!=1 && $curr_line!=2)
{
switch((($curr_line-3)%6))
{
case 0:
break;
case 1:
echo "</td>";
break;
case 2:
echo "</td>";
break;
case 3:
echo "</td>";
break;
case 4:
echo "</td>";
break;
case 5:
echo "\n</tr>";
break;
}
}
}
function mycdata($parser, $cdata)
{
echo $cdata;
}
function parse($data)
{
xml_parse($this->parser,$data);
}
}$xml_parser = new myxml();
$xmlfilename = "students.xml";
$fp = fopen($xmlfilename, "r");
$xmldata = fread($fp, filesize($xmlfilename));echo "<table border=1 width=100%>";
echo "<tr>";
echo "<td>id</td>";
echo "<td>name</td>";
echo "<td>password</td>";
echo "<td>test</td>";
echo "</tr>";
$xml_parser->parse($xmldata);
echo "</table>";
?>
<USERMANAGEMENT>
<students>
<student>
<id>1</id>
<name>aa</name>
<password>password</password>
<test>test</test>
</student>
<student>
<id>2</id>
<name>bb</name>
<password>password</password>
<test>test</test>
</student>
<student>
<id>3</id>
<name>cc</name>
<password>password</password>
<test>test</test>
</student>
</students>
</USERMANAGEMENT>
</XML><table border=1 width=100% id='studentslist' datapagesize='20' datasrc='#studentsinfo'>
<thead>
<tr>
<td>id</td>
<td>name</td>
<td>password</td>
</tr>
<tbody>
<tr>
<td><span datafld='id'></span></td>
<td><span datafld='name'></span></td>
<td><span datafld='password'></span></td>
</tr>
<tfoot>
<tr>
<td width="600" colspan="3">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="first.gif" onclick="languagelist.firstPage()">
</td>
<td>
<img src="back.gif" onclick="languagelist.previousPage()">
</td>
<td>
<img src="next.gif" onclick="languagelist.nextPage()">
</td>
<td>
<img src="last.gif" onclick="languagelist.lastPage()">
</td>
</tr>
</table>
</td>
</tr>
</table>