Codeigniter通过SimpleXML将xml转换成对象的方法
本文实例讲述了Codeigniter通过SimpleXML将xml转换成对象的方法。分享给大家供大家参考。具体分析如下:
SimpleXML是一个php扩展,有了它可以非常容易的操作xml文件
classCI_ManipulateXML
{
var$xml='';
functionCI_ManipulateXML($xmlcontent)
{
$this->xml=$xmlcontent;
}
functionConvertXML(){
try{
$xmlobject=newSimpleXMLElement($this->xml);
if($xmlobject==false){
returnfalse;
}
}
catch(Exception$e){
returnfalse;
}
return$xmlobject;
}
}
希望本文所述对大家的基于Codeigniter框架的php程序设计有所帮助。