In: ajax
27 十 2006<?php /* 作者: qk31 作用:数据库数据生成xml文件进行简单的封装 */ class xmlCreate { var $msg; var $encode; var $sumMsg; function xmlCreate($encode,$array,$sum) { $this->setXmlHeader($encode);//设置编码 $this->setSumMsg($sum); //设置记录总数 $this->setMsg($array); //设置留言信息处理 } /*设定xml的编码和头部*/ function setXmlHeader($encode) { header(“Content-Type:text/html;charset=$encode”); header(“Content-type: text/xml”); $this->msg.=”<?xml version=\”1.0\” encoding=\”$encode\”?>”; } /*设定生成xml文件*/ function setMsg($array) { $this->msg.=”<main>”; $this->msg.=”<nums>”.$this->sumMsg.”</nums>”; $this->xmlAddTag($array); $this->msg.=”</main>”; } /*为数据库字段添加xml标签*/ function xmlAddTag($array) { $i=1; foreach ($array as $row) { $this->msg.=”<row [...]
In: ajax
29 八 2006例子来源:<<ajax in action>>第十二章使用xslt的动态搜索 程序结构: 利用php根据ajax发过来的请求生成一个xml文件 xml格式如下: QUOTE: <?xml version=”1.0″ ?> <phonebook> <entry id=’1′> <company>ABC</company> <contact>Dave Crane</contact> <country>UK</country> <phone>123456789</phone> </entry> <entry id=’2′> <company>XYZ</company> <contact>Eric Pascarello</contact> <country>USA</country> <phone>123456789</phone> </entry> </phonebook> 再套用xsl,样式表(类似于css) QUOTE: <?xml version=”1.0″ encoding=”ISO-8859-1″?> <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:template match=”/”> <!——-这里是对表格标题定义——> <table id=”table1″> <tr> <th align=”left”>Company</th> <th align=”left”>Contact</th> [...]
最近评论