最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php simpleXML添加CDATA格式数据
时间:2022-06-24 20:50:39 编辑:袖梨 来源:一聚教程网
代码
| 代码如下 | 复制代码 |
|
/** * */ class SimpleXMLExtended extends SimpleXMLElement { public function addCData($cdata_text) { $node = dom_import_simplexml($this); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($cdata_text)); } } $xmlFile = 'config.xml'; // instead of $xml = new SimpleXMLElement(' $xml = new SimpleXMLExtended(' $site = $xml->addChild('site'); // instead of $site->addChild('site', 'Site Title'); $site->title = NULL; // VERY IMPORTANT! We need a node where to append $site->title->addCData('Site Title'); $site->title->addAttribute('lang', 'en'); $xml->asXML($xmlFile); ?> |
|
相关文章
- picacg哔咔testflight版-picacg官网最新版 03-06
- 羞羞漫画全集免费在线阅读-羞羞漫画在线阅读完整版 03-06
- jm漫画网页版免费登录教程-jm漫画网页版入口 03-06
- poki游戏一键畅玩-poki游戏在线免登入口 03-06
- picacg哔咔testflight下载-picacg官网入口 03-06
- 知乎小说免费阅读网站入口-知乎小说免费阅读网站推荐 03-06