note 89430 modified in function.simplexml-load-string by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Mar 2009 18:08:28 +0000 |
| Subject: | note 89430 modified in function.simplexml-load-string by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151594@lists.php.net to get a copy of this message | ||
if we don't know children number. How many loop. How many key.
<?php
class XML {
protected $pointer;
public $degerler=array();
function loadString($string){
$this->pointer = simplexml_load_string($string);
return $this->pointer;
}
function loadFile($file){
$this->pointer = simplexml_load_file($file);
return $this->pointer;
}
function getname(){
return $this->pointer->getName();
}
function child(){
return $this->pointer->children();
}
function att(){
return $this->pointer->attributes();
}
function toArray(){
foreach ($this->child() as $sq){
$this->degerler[$this->getname()][$sq->getname()][][] = $sq; // How many key
}
return;
}
}
?>
--was--
if we don't know children number. How many loop. How many key.
class XML {
protected $pointer;
public $degerler=array();
function loadString($string){
$this->pointer = simplexml_load_string($string);
return $this->pointer;
}
function loadFile($file){
$this->pointer = simplexml_load_file($file);
return $this->pointer;
}
function getname(){
return $this->pointer->getName();
}
function child(){
return $this->pointer->children();
}
function att(){
return $this->pointer->attributes();
}
function toArray(){
foreach ($this->child() as $sq){
$this->degerler[$this->getname()][$sq->getname()][][] = $sq; // How many key
}
return;
}
}
http://php.net/manual/en/function.simplexml-load-string.php