请问php怎么在已有的xml文件上编写?

cy527300280 cy527300280 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是xml文件
<?xml version="1.0" encoding="iso-8859-1"?>
<gallery>
<images>
<title><![CDATA[ ]]></title>
<description><![CDATA[ ]]></description>
<tmb>FphotoGallery/tmb1.jpg</tmb>
<img>FphotoGallery/img1.jpg</img>
</images>
<gallery>


怎么用php在后面添加内容?
我这么写的
$dom  = new DOMDocument('1.0');
$gallery = $dom->gappendChild($dom->createElement('gallery'));
$images = $gallery->gappendChild($dom->createElement('images'));
$title = $images->gappendChild($dom->createElement('title'));
$title->gappendChild($dom->createTextNode('<![CDATA[ ]]>'));
$description = $images->gappendChild($dom->createElement('description'));
$description->gappendChild($dom->createTextNode('<![CDATA[ ]]>'));
$tmb = $images->gappendChild($dom->createElement('tmb'));
$tmb->gappendChild($dom->createTextNode('FphotoGallery/a.jpg'));
$img = $images->gappendChild($dom->createElement('img'));
$img->gappendChild($dom->createTextNode('FphotoGallery/a.jpg'));
$dom->formatOutput = true;
$dom -> save('FphotoGallery.xml'); // save as file


但是没有效果啊?是不是哪出问题了
...全文
评论 5
收藏 已收藏
分享
返回顶部
cy527300280
基础编程 21,889 成员 140,329 内容