SimpleXMLElement->asXML Return a well-formed XML string based on SimpleXML element Description stringSimpleXMLElement->asXML The asXML method formats the parent object's data in XML version 1.0. Get XML text stuff code XML; $xml = simplexml_load_string($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 } ?> ]]>