$doc = new DOMDocument();
$doc->formatOutput = true;
$root = $doc->createElement( "bcaster" );
$doc->appendChild( $root ); $url1 = $doc->createElement( "images/flash/01.jpg" );(这里不知道能不能写图片)
其他依次和上面一样$doc->createTextNode($root['images/flash/01.jpg']);
$root->appendChild($url1);
.......$doc->saveXML();
$doc->formatOutput = true;
$root = $doc->createElement( "bcaster" );
$doc->appendChild( $root ); $url1 = $doc->createElement( "images/flash/01.jpg" );(这里不知道能不能写图片)
其他依次和上面一样$doc->createTextNode($root['images/flash/01.jpg']);
$root->appendChild($url1);
.......$doc->saveXML();
header("Content-type:text/xml");
$array=array('01.jpg','02.jpg','03.jpg','04.jpg');
$tem[]="<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
$tem[]="<bcaster autoPlayTime=\"10\">";
foreach($array as $v){
$tem[]="<item item_url=\"images/flash/{$v}\" link=\"#\" > </item> ";
//echo "<item item_url=\"images/flash/{$v}\" link=\"#\" > </item> ";
}
$tem[]="</bcaster>";$f=fopen("a.xml","w");
fputs($f,join("",$tem));
fclose($f);
?>
http
ehco 或保存$str到文件要header();指定为utf8类型
header("Content-type:text/xml");
header("Content-Disposition: attachment; filename=bcaster.xml");
?>
<?xml version="1.0" encoding="utf-8"?>
<bcaster autoPlayTime="10">
<item item_url="images/flash/01.jpg" link="#"></item>
<item item_url="images/flash/02.jpg" link="#"></item>
<item item_url="images/flash/03.jpg" link="#" ></item>
<item item_url="images/flash/04.jpg" link="#"></item>
<item item_url="images/flash/05.jpg" link="#" ></item>
</bcaster>
上面的方法行吗?
还80分,是不是小马甲LZ带的3楼大马甲阿
<page src="pages/01.jpg"/>
<page src="pages/02.swf"/>
<page src="pages/03.swf"/>
<page src="pages/04.jpg"/>
<page src="pages/05.jpg"/>
<page src="pages/06.jpg"/>
<page src="pages/07.swf"/>
<page src="pages/08.jpg"/>
<page src="pages/09.swf"/>
<page src="pages/10.jpg"/>
</content>
我想问一下,我想生成这样的又应该如何写呢,我在PHP文件中
$doc=new DOMDocument("1.0","gb2312"); #声明文档类型
$doc->formatOutput=true; #设置可以输出操作#声明根节点,最好一个XML文件有个跟节点
$info=$doc->createElement("info"); #创建节点对象实体
$info=$doc->appendChild($info); #把节点添加进来
for($i=1;$i<100;$i++){ //循环生成节点,如果数据库调用出来就改这里
$name=$doc->createElement("name"); #创建节点对象实体
$name=$info->appendChild($name);
$name->appendChild($doc->createTextNode("adevy001")); #createTextNode创建内容的子节点,然后把内容添加到节点中来
}
$doc->save("info.xml"); #保存路径
echo "生成成功。";?>
按这来生成,但是好像总和这不对。