SimpleXMLElement->asXML
Return a well-formed XML string based on SimpleXML element
&reftitle.description;
mixedSimpleXMLElement->asXMLstringfilename
The asXML method formats the parent object's data
in XML version 1.0.
&reftitle.parameters;
filename
If specified, the function writes the data to the file rather than
returning it.
&reftitle.returnvalues;
If the filename isn't specified, this function
returns a string on success and &false; on error. If the
parameter is specified, it returns &true; if the file was written
successfully and &false; otherwise.
&reftitle.examples;
Get XMLtextstuffcode
XML;
$xml = simplexml_load_string($string);
echo $xml->asXML(); // textstuff ...
?>
]]>
asXML also works on Xpath results:
Using asXML() on
Xpath
results
*/
$result = $xml->xpath('/a/b/c');
while(list( , $node) = each($result)) {
echo $node->asXML(); // text and stuff
}
?>
]]>