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