if ($parsed->xpath_exists('//plain')) { @nodes = $parsed->xpath_findnodes('//plain'); $text_part = $nodes[0]; $body=$text_part->body; }