SimpleXMLElement->asXML Return a well-formed XML string based on SimpleXML element &reftitle.description; SimpleXMLElement mixedasXML stringfilename 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 XML text stuff code XML; $xml = new SimpleXMLElement($string); echo $xml->asXML(); // textstuff ... ?> ]]> asXML also works on Xpath results: Using asXML() on <link linkend="function.simplexml-element-xpath">Xpath</link> results */ $result = $xml->xpath('/a/b/c'); while(list( , $node) = each($result)) { echo $node->asXML(); // text and stuff } ?> ]]>