最近写一个重写xml文件的程序,没有什么要求,就是编码上边有些困惑,不废话,上代码.
$xml = new SimpleXMLElement(''); foreach ( $result as $k => $v ) { $thumb = $xml->addChild('thumbnail'); $thumb->addAttribute('title', $v['title']); $thumb->addAttribute('target', '_parent'); $thumb->addAttribute('url', 'http://www.zgweb.com'); $thumb->addAttribute('filename', "{ $catid}_{ $contentid}.jpg"); $thumb->addAttribute('description', $v['description']); } $xml->asXML(MG_WEBEXH_ROOT.$xmlFile);
2.木有了.