1
A
回答
0
从这节课:
class ExSimpleXMLElement extends SimpleXMLElement
{
public function _construct($xml){
parent::_construct($xml);
}
/**
* Add SimpleXMLElement code into a SimpleXMLElement
* @param SimpleXMLElement $append
*/
public function appendXML($append)
{
if ($append) {
if (strlen(trim((string) $append))==0) {
$xml = $this->addChild($append->getName());
foreach($append->children() as $child) {
$xml->appendXML($child);
}
} else {
$xml = $this->addChild($append->getName(), (string) $append);
}
foreach($append->attributes() as $n => $v) {
$xml->addAttribute($n, $v);
}
}
}
}
你会改变这样的:
<?php
class ExSimpleXMLElement
{
private $sxe;
public function loadXml($xml){
$this->sxe = new SimpleXMLElement($xml);
}
/**
* Add SimpleXMLElement code into a SimpleXMLElement
* @param SimpleXMLElement $append
*/
public function appendXML($append)
{
if ($append) {
if (strlen(trim((string) $append))==0) {
$xml = $this->sxe->addChild($append->getName());
foreach($append->children() as $child) {
$xml->appendXML($child);
}
} else {
$xml = $this->sxe->addChild($append->getName(), (string) $append);
}
foreach($append->attributes() as $n => $v) {
$xml->addAttribute($n, $v);
}
}
}
}
而且使用这样的:
$this->load->library('ExSimpleXMLElement');
$this->exsimplexmlelement->loadXML($xml);
相关问题
- 1. 将AWS SDK作为库集成到Codeigniter中
- 2. 如何在codeigniter 2中集成zend库?
- 3. Codeigniter PDO集成
- 4. Codeigniter-phpBB集成
- 5. Codeigniter - 集成tank_auth - 问题加载库
- 6. 集成CodeIgniter库(如坦克认证)
- 7. 作为Codeigniter中的Singleton的库?
- 8. 集成aweber在codeigniter中
- 9. Codeigniter和Tomcat集成
- 10. CodeIgniter +引导集成
- 11. CodeIgniter和Wordpress集成
- 12. 集成codeigniter和wordpress授权
- 13. codeigniter nodejs和nowjs集成
- 14. Codeigniter-oauth2-服务器集成
- 15. 谷歌结帐集成 - codeigniter
- 16. Codeigniter和角度js集成
- 17. CodeIgniter和WordPress集成路由
- 18. 集成Wordpress,Codeigniter和.htaccess
- 19. CodeIgniter语言类库不工作
- 20. 将结果集转换为codeigniter中的数据库对象
- 21. PayPal Express Checkout集成在CodeIgniter中
- 22. 如何在codeigniter中集成google reCAPTCHA?
- 23. 在Codeigniter中集成FPDI和TCPDF
- 24. 如何将模板集成到Codeigniter中?
- 25. 在CodeIgniter中集成Blueimp(Jquery上传器)
- 26. 在codeigniter中集成SMS打印机
- 27. 编译外部库作为集中使用类在Java中
- 28. 替代为其他类使用codeigniter库
- 29. 集成PHP喜欢和不像成codeigniter
- 30. Android:将Crashlytics集成到Android库中,将作为AAR分发
感谢reponder machineaddict – Corematrixx
machineaddict。我尝试了代码,并得到错误图像,这可能是?我打电话利比里亚这样: [链接](https://docs.google.com/file/d/0B4eow_YS2Y1eVjFaQV9HRlNCcWM/edit) ''公共职能edit_svg(){ $这个 - >负载>库( 'ExSimpleXMLElement'); $ file =“images/designs/svg/a.svg”; //http://www.webdeveloper.com/forum/showthread.php?165648-Editing-XML-using-PHP $ xml = simplexml_load_file($ file); //加载文件。 $ this-> exsimplexmlelement-> loadXML($ xml)'' – Corematrixx
而不是'$ xml = simplexml_load_file($ file);',使用'$ xml = file_get_contents($ file);'。 'loadXML'方法需要xml作为字符串。 – machineaddict