PHP Class Prado\Xml\TXmlElement

TXmlElement represents an XML element node. You can obtain its tag-name, attributes, text between the opening and closing tags via the TagName, Attributes, and Value properties, respectively. You can also retrieve its parent and child elements by Parent and Elements properties, respectively. TBD: xpath
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends Prado\TComponent
Show file Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
__construct ( $tagName ) Constructor.
__toString ( ) : string Magic-method override. Called whenever this element is used as a string.
getAttribute ( $name ) : string
getAttributes ( ) : TMap
getElementByTagName ( $tagName ) : TXmlElement
getElements ( ) : TXmlElementList
getElementsByTagName ( $tagName ) : Prado\Collections\TList
getHasAttribute ( ) : boolean
getHasElement ( ) : boolean
getParent ( ) : TXmlElement
getTagName ( ) : string
getValue ( ) : string
setAttribute ( $name, $value )
setParent ( $parent )
setTagName ( $tagName )
setValue ( $value )
toString ( $indent ) : string

Private Methods

Method Description
xmlEncode ( $str )

Method Details

__construct() public method

Constructor.
public __construct ( $tagName )

__toString() public method

$element = new TXmlElement('tag'); echo $element; or $element = new TXmlElement('tag'); $xml = (string)$element;
public __toString ( ) : string
return string string representation of this element

getAttribute() public method

public getAttribute ( $name ) : string
return string the attribute specified by the name, null if no such attribute

getAttributes() public method

public getAttributes ( ) : TMap
return Prado\Collections\TMap list of attributes

getElementByTagName() public method

public getElementByTagName ( $tagName ) : TXmlElement
return TXmlElement the first child element that has the specified tag-name, null if not found

getElements() public method

public getElements ( ) : TXmlElementList
return TXmlElementList list of child elements

getElementsByTagName() public method

public getElementsByTagName ( $tagName ) : Prado\Collections\TList
return Prado\Collections\TList list of all child elements that have the specified tag-name

getHasAttribute() public method

public getHasAttribute ( ) : boolean
return boolean true if this element has attributes

getHasElement() public method

public getHasElement ( ) : boolean
return boolean true if this element has child elements

getParent() public method

public getParent ( ) : TXmlElement
return TXmlElement parent element of this element

getTagName() public method

public getTagName ( ) : string
return string tag-name of this element

getValue() public method

public getValue ( ) : string
return string text enclosed between opening and closing tag of this element

setAttribute() public method

public setAttribute ( $name, $value )

setParent() public method

public setParent ( $parent )

setTagName() public method

public setTagName ( $tagName )

setValue() public method

public setValue ( $value )

toString() public method

public toString ( $indent ) : string
return string string representation of this element