| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
class CJT_Framework_Xml_Fetchscalars extends ArrayIterator { |
| 10 |
|
| 11 |
/** |
| 12 |
* put your comment there... |
| 13 |
* |
| 14 |
* @param SimpleXMLElement $element |
| 15 |
* @return CJT_Framework_Xml_Fetchscalars |
| 16 |
*/ |
| 17 |
public function __construct(SimpleXMLElement $element) { |
| 18 |
$data = array(); |
| 19 |
// Read all Child elements with no childs inside. |
| 20 |
foreach ($element->children() as $field => $child) { |
| 21 |
// Read all elements with no childs inside! |
| 22 |
// Only with text data! |
| 23 |
if (!count($child->children())) { |
| 24 |
$data[$field] = (string) $child; |
| 25 |
} |
| 26 |
} |
| 27 |
// Load array iterator with fetched data. |
| 28 |
parent::__construct($data); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
} // End class. |