音乐文件 XML 的格式大致上可能是 HTML: <?xml version="1.0" encoding="utf-8" ?> <playlist> <item> <title></title> <author></author> <url></url> </item> .... </playlist> 那么你只要根据找到的音乐信息来重复生成<item> 节点就可以了。 原理如此。
遍历文件夹,echo PHP: <?php class listfile{ var $callFunc; //操作函数,用于lisDirTree里的调用 var $extname; //有效文本文件的扩展名。 function listfile() { echo 'initialize filetree<BR>'; } // end func /** 函数 listDirTree( $dirName = null ) * 功能 对目录下所有文件及子目录下所有文件进行操作 * 参数 $dirName 目录名称 */ function listDirTree( $dirName = null ) {//global $tree; if( empty( $dirName ) ) exit( "IBFileSystem: directory is empty." ); if( is_dir( $dirName ) ) { if( $dh = opendir( $dirName ) ) { //$tree = array(); while( ( $file = readdir( $dh ) ) !== false ) { if( $file != "." && $file != ".." ) { $filePath = $dirName . "/" . $file; if( is_dir( $filePath ) )//为目录,递归 { //$tree[$file] = $this->listDirTree( $filePath ); $this->listDirTree( $filePath ); } else//为文件,进行处理 { //echo "文件处理函数为 $this->callFunc <BR>"; eval($this->callFunc); //$tree[] = $file; } //文件处理结束 } } closedir( $dh ); } else { exit( "IBFileSystem: can not open directory $dirName."); } //返回当前的$tree //return $tree; } else { exit( "IBFileSystem: $dirName is not a directory."); } }//</listDirTree> /** * mkdirp is used to instead of mkdir ,mkdirp can create deep multiple directory. */ function mkdirp($target) { // If the path already exists && is a directory, all is well. // If the path is not a directory, we've a problem. if (file_exists($target)) { if (!is_dir($target)) return false; else return true; } // Attempting to create the directory may clutter up our display. if ( @mkdir($target) ) return true; // If the above failed, attempt to create the parent node, then try again. if ( $this->mkdirp(dirname($target)) ) return $this->mkdirp($target); return false; }//</function mkdirp> }//</class listfile> ?> echo.php <?php function echot(&$str){ echo '<TEXTAREA NAME="" ROWS="5" COLS="80">'.$str.'</TEXTAREA>'; } /** * echothead */ function echothead() { echo '<TEXTAREA NAME="" ROWS="20" COLS="80">'; } // end func echothead /** * echotfoot */ function echotfoot() { echo "</textarea>"; } // end func function pr(&$row){ echo "<pre>"; print_R($row); } function echosql($q){ $q = str_replace("#_","mos",$q); echo "$q <br/>\n"; } function echoredsql($q){ $q = str_replace("#_","mos",$q); echo "<font color=red> $q </font>\n"; } function echored($str){ echo "<font color=red> $str </font>\n"; } /** * show table,$rows is get by $database->loadOjbectLIst(); */ function rowstable(&$rows) {$n=count($rows); if ($n>0) { //pr($rows); $obj = $rows[0]; $fields=get_object_vars($obj) ;// pr($fields); $cnt = "<table class=\"dxtable\">\n"; for ($i=0;$i<$n ;$i++ ) { $cnt .="<tr>\n"; foreach($fields as $key=>$value){ //echo "$key=$value"; $cnt .= "<td>".$rows[$i]->$key."</td>\n"; } $cnt .="</tr>\n"; } $cnt.="</table>\n"; echo $cnt; } } // end func /** * prt */ function prt($arr) { echothead(); print_R($arr); echotfoot(); } // end func ?>
HTML: <%@ Language=VBScript %> <% function bianli(path) dim fso 'fso对象 dim objFolder '文件夹对象 dim objSubFolders '子文件夹集合 dim objSubFolder '子文件夹对象 dim objFiles '文件集合 dim objFile '文件对象 set fso=server.CreateObject("scripting.filesystemobject") on error resume next set objFolder=fso.GetFolder(path)'创建文件夹对象 set objSubFolders=objFolder.Subfolders'创建的子文件夹对象 for each objSubFolder in objSubFolders nowpath=path + "\\" + objSubFolder.name Response.Write nowpath set objFiles=objSubFolder.Files for each objFile in objFiles Response.Write "<br>---" Response.Write objFile.name next Response.Write "<p>" bianli(nowpath) '调用递归 next set objFolder=nothing set objSubFolders=nothing set fso=nothing end function %> <% bianli("F:\") '调用bianli()函数,这里是遍历F:盘 %>