<?php
$xmlpatch = 'index.xml';
$doc=new DOMDocument("1.0","utf-8");
$doc->formatOutput=true;
$document=$doc->createElement("document");
$document=$doc->appendChild($document);
$dc = $doc->createAttribute("xmlns:dc");
$dc = $document->appendChild($dc);
$dc->appendChild($doc->createTextNode("http://purl.org/dc/elements/1.1/"));
/*
$item = $doc -> createElement('item');//新建节点
$url = $doc -> createAttribute('url');//新建属性
$patch = $doc -> createTextNode('url值');//新建TEXT值
$url -> appendChild($patch);//将$patch文本设为$url属性的值
$item -> appendChild($url);//将$id设为item节点的属性,以下类同
$id = $doc -> createAttribute('id');//新建属性
$newsid = $doc -> createTextNode('id值');//新建TEXT值
$id -> appendChild($newsid);//将$newsid文本设为$id属性的值
$item -> appendChild($id);//将$id设为item节点的属性,以下类同
$title = $doc -> createAttribute('title');
$newstitle = $doc -> createTextNode('title值');
$title -> appendChild($newstitle);
$item -> appendChild($title);
$author = $doc -> createAttribute('author');
$newsauthor = $doc -> createTextNode('author值');
$author -> appendChild($newsauthor);
$item -> appendChild($author);
$sendtime = $doc -> createAttribute('time');
$newssendtime = $doc -> createTextNode('time值');
$sendtime -> appendChild($newssendtime);
$item -> appendChild($sendtime);
$content = $doc -> createTextNode('内容值content');//节点值
$item -> appendChild($content);
$document -> appendChild($item);
$doc -> appendChild($document);
$doc -> save($xmlpatch);//保存文件
echo $xmlpatch . ' has create success';
*/
$webName=$doc->createElement("webName");
$webName=$document->appendChild($webName);
$webName->appendChild($doc->createCDATASection("名称"));
$webName=$doc->createElement("webSite");
$webName=$document->appendChild($webName);
$webName->appendChild($doc->createCDATASection("http://domain/"));
for($i=1;$i<10;$i++){
$item=$doc->createElement("item");
$item=$document->appendChild($item);
$date1=$doc->createAttribute("id");
$date1=$item->appendChild($date1);
$date1->appendChild($doc->createTextNode($i));
//操作
$webName=$doc->createElement("op");
$webName=$item->appendChild($webName);
$webName->appendChild($doc->createTextNode("add"));
$url = $doc -> createAttribute('url');//新建属性
$patch = $doc -> createTextNode("http://domain/".$i);//新建TEXT值
$url -> appendChild($patch);//将$patch文本设为$url属性的值
$webName->appendChild($url);
$id = $doc -> createAttribute('id');
$newsid = $doc -> createTextNode($i);
$id -> appendChild($newsid);
$webName->appendChild($id);
//影片质量
$webName=$doc->createElement("att");
$webName=$item->appendChild($webName);
$webName->appendChild($doc->createTextNode("hd"));
$title = $doc -> createAttribute('title');
$newstitle = $doc -> createTextNode('title'.$i);
$title -> appendChild($newstitle);
$sendtime = $doc -> createAttribute('time');
$newssendtime = $doc -> createTextNode(time());
$sendtime -> appendChild($newssendtime);
$webName->appendChild($title);
$webName->appendChild($sendtime);
//片名
$webName=$doc->createElement("title");
$webName=$item->appendChild($webName);
$webName->appendChild($doc->createCDATASection('title'.$i));
$author = $doc -> createAttribute('author');
$newsauthor = $doc -> createTextNode('author'.$i);
$author -> appendChild($newsauthor);
$webName->appendChild($author);
//dc:creator
$creator = $doc->createElement("dc:creator");
$creator = $item->appendChild($creator);
$creator->appendChild($doc->createCDATASection('dcauthor'.$i));
}
$doc -> save($xmlpatch);//保存文件
echo $xmlpatch . ' has create success';
?>
$xmlpatch = 'index.xml';
$doc=new DOMDocument("1.0","utf-8");
$doc->formatOutput=true;
$document=$doc->createElement("document");
$document=$doc->appendChild($document);
$dc = $doc->createAttribute("xmlns:dc");
$dc = $document->appendChild($dc);
$dc->appendChild($doc->createTextNode("http://purl.org/dc/elements/1.1/"));
/*
$item = $doc -> createElement('item');//新建节点
$url = $doc -> createAttribute('url');//新建属性
$patch = $doc -> createTextNode('url值');//新建TEXT值
$url -> appendChild($patch);//将$patch文本设为$url属性的值
$item -> appendChild($url);//将$id设为item节点的属性,以下类同
$id = $doc -> createAttribute('id');//新建属性
$newsid = $doc -> createTextNode('id值');//新建TEXT值
$id -> appendChild($newsid);//将$newsid文本设为$id属性的值
$item -> appendChild($id);//将$id设为item节点的属性,以下类同
$title = $doc -> createAttribute('title');
$newstitle = $doc -> createTextNode('title值');
$title -> appendChild($newstitle);
$item -> appendChild($title);
$author = $doc -> createAttribute('author');
$newsauthor = $doc -> createTextNode('author值');
$author -> appendChild($newsauthor);
$item -> appendChild($author);
$sendtime = $doc -> createAttribute('time');
$newssendtime = $doc -> createTextNode('time值');
$sendtime -> appendChild($newssendtime);
$item -> appendChild($sendtime);
$content = $doc -> createTextNode('内容值content');//节点值
$item -> appendChild($content);
$document -> appendChild($item);
$doc -> appendChild($document);
$doc -> save($xmlpatch);//保存文件
echo $xmlpatch . ' has create success';
*/
$webName=$doc->createElement("webName");
$webName=$document->appendChild($webName);
$webName->appendChild($doc->createCDATASection("名称"));
$webName=$doc->createElement("webSite");
$webName=$document->appendChild($webName);
$webName->appendChild($doc->createCDATASection("http://domain/"));
for($i=1;$i<10;$i++){
$item=$doc->createElement("item");
$item=$document->appendChild($item);
$date1=$doc->createAttribute("id");
$date1=$item->appendChild($date1);
$date1->appendChild($doc->createTextNode($i));
//操作
$webName=$doc->createElement("op");
$webName=$item->appendChild($webName);
$webName->appendChild($doc->createTextNode("add"));
$url = $doc -> createAttribute('url');//新建属性
$patch = $doc -> createTextNode("http://domain/".$i);//新建TEXT值
$url -> appendChild($patch);//将$patch文本设为$url属性的值
$webName->appendChild($url);
$id = $doc -> createAttribute('id');
$newsid = $doc -> createTextNode($i);
$id -> appendChild($newsid);
$webName->appendChild($id);
//影片质量
$webName=$doc->createElement("att");
$webName=$item->appendChild($webName);
$webName->appendChild($doc->createTextNode("hd"));
$title = $doc -> createAttribute('title');
$newstitle = $doc -> createTextNode('title'.$i);
$title -> appendChild($newstitle);
$sendtime = $doc -> createAttribute('time');
$newssendtime = $doc -> createTextNode(time());
$sendtime -> appendChild($newssendtime);
$webName->appendChild($title);
$webName->appendChild($sendtime);
//片名
$webName=$doc->createElement("title");
$webName=$item->appendChild($webName);
$webName->appendChild($doc->createCDATASection('title'.$i));
$author = $doc -> createAttribute('author');
$newsauthor = $doc -> createTextNode('author'.$i);
$author -> appendChild($newsauthor);
$webName->appendChild($author);
//dc:creator
$creator = $doc->createElement("dc:creator");
$creator = $item->appendChild($creator);
$creator->appendChild($doc->createCDATASection('dcauthor'.$i));
}
$doc -> save($xmlpatch);//保存文件
echo $xmlpatch . ' has create success';
?>