网站首页一个flash的幻灯片加载xml文件需要将文件的生成代码写到xml文件内,使用如下代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?php $sxml=
""
;?>
{pc:content action=
"position"
siteid=
"$siteid"
posid=
"1"
isthumb=
"1"
order=
"listorder desc"
num=
"4"
}
{loop $data $r}
<?php
$sxml.=
"<menu url='"
.$r['url
']."'
frame=
'_parent'
imageUrl=
'".$r['
thumb
']."'
/>";
?>
{/loop}
{/pc}
<?php
$sxml=
"<?xml version='1.0' encoding='utf-8'?><root imageWidth='680' imageHeight='345'>"
.$sxml.
"</root>"
;
$file=
"("
phpcms_org_cn/xml/images.xml";
$fp = fopen($file,
"w"
);
if
($fp){
fwrite($fp,$sxml);
fclose($fp);
}
?>
|
查看images.xml是全站首页的所有代码,进行精简,把:
$file="("phpcms_org_cn/xml/images.xml";
$fp = fopen($file,"w");
合成一句 :
$fp = fopen("phpcms_org_cn/xml/images.xml","w");