SimpleXML增加CDATA功能
PHP扩展的SimpleXML默认是不带CDATA标识的,可以使用下面这个类继承SimpleXMLElement然后再实例化:
<?php class SimpleXMLExtended extends SimpleXMLElement { public function addCData($cdata_text) { $node = dom_import_simplexml($this); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($cdata_text)); } }
本文地址:http://blog.zhengshuiguang.com/php/simplexml-cdata.html
转载随意,但请附上文章地址:-)
评论已关闭