0
在CI中的一個模型中,我需要創建一個SimpleXmlElement
對象,但我需要首先擴展它以使用CDATA。使用字符串參數在Codeigniter中加載擴展庫
所以我創建了一個庫:
class SimpleXMLExtended extends SimpleXMLElement
{
public function addCData($cdata_text)
{
$node = dom_import_simplexml($this);
$no = $node->ownerDocument;
$node->appendChild($no->createCDATASection($cdata_text));
}
}
然後在我的模型我加載這個庫:
$template = $this->load->library('SimpleXMLExtended', 'xml_template.php');
但由於SimpleXMLElement
需要一個字符串參數(和笨只能通過根據陣列文檔)它顯示錯誤: SimpleXMLElement::__construct() expects at least 1 parameter, 0 given
。
那麼我想如何加載這個庫?