| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
class CJT_Framework_Html_Dom_Elementbase { |
| 7 |
|
| 8 |
/** |
| 9 |
* put your comment there... |
| 10 |
* |
| 11 |
* @var SimpleXMLElement |
| 12 |
*/ |
| 13 |
protected $simpleXML; |
| 14 |
|
| 15 |
/** |
| 16 |
* put your comment there... |
| 17 |
* |
| 18 |
* @param mixed $tag |
| 19 |
* @return CJT_Framework_Html_Dom_Elementbase |
| 20 |
*/ |
| 21 |
public function __construct($tag) { |
| 22 |
// Build XML Content. |
| 23 |
$xmlContent = "<root><{$tag}></{$tag}></root>"; |
| 24 |
// Create SIMPLEXMLElement. |
| 25 |
$this->simpleXML = new SimpleXMLElement($xmlContent); |
| 26 |
// Target the tag element. |
| 27 |
$children = $this->getSimpleXML()->children(); |
| 28 |
$this->simpleXML = $children[0]; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* put your comment there... |
| 33 |
* |
| 34 |
*/ |
| 35 |
public function __toString() { |
| 36 |
return $this->getSimpleXML()->asXML(); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* put your comment there... |
| 41 |
* |
| 42 |
*/ |
| 43 |
protected function & getSimpleXML() { |
| 44 |
return $this->simpleXML; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* put your comment there... |
| 49 |
* |
| 50 |
* @param mixed $name |
| 51 |
* @param mixed $value |
| 52 |
* @param mixed $ns |
| 53 |
*/ |
| 54 |
public function setAttribute($name, $value, $ns = null) { |
| 55 |
return $this->getSimpleXML()->addAttribute($name, $value, $ns); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* put your comment there... |
| 60 |
* |
| 61 |
* @param mixed $content |
| 62 |
*/ |
| 63 |
public function & setContent($content) { |
| 64 |
// Set content. |
| 65 |
$this->getSimpleXML()->{0} = $content; |
| 66 |
// Chain. |
| 67 |
return $this; |
| 68 |
} |
| 69 |
} // End class. |
| 70 |
|