SimpleXMLElement::__toString
PHP function
Edit on GitHub ✎
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
Returns the string content
Description
SimpleXMLElement::__toString(): string
Returns text content that is directly in this element. Does not return text content that is inside this element's children.
Parameters Parameters
Return Values
Returns the string content on success or an empty string on failure.
Examples
Get string content
php
<?php
$xml = new SimpleXMLElement('<a>1 <b>2 </b>3</a>');
echo $xml;
?>The above example will output:
output
1 3See Also
SimpleXMLElement::asXML