I'm sure there's an easier, possibly faster way to use Perl's regular expression syntax to achieve this, but I would do this as such:
$start = '<VirtualHost 000.1.000.000>';
$start_pos = strpos($file_contents, $start);
if($start_pos === FALSE) die('VirtualHost not found in file.');
$end = '</VirtualHost>';
$end_pos = strpos($file_contents, $end, $start_pos);
if($end_pos === FALSE) die('File incorrectly formatted; VirtualHost tag is not terminated.');
$config_data = substr($file_contents, $start_pos,($end_pos - $start_pos));
if($config_data == "") die('Error parsing file.');
$document_root_keyword = 'DocumentRoot ';
$document_root_start = strpos($config_data, $document_root_keyword);
$document_root_end = strpos($config_data, "\n", $document_root_start);
$document_root = substr($config_data, $document_root_start + strlen($document_root_keyword), ($document_root_end - $document_root_start - strlen($document_root_keyword)));
$server_name_keyword = 'ServerName ';
$server_name_start = strpos($config_data, $server_name_keyword);
$server_name_end = strpos($config_data, "\n", $server_name_start);
$server_name = substr($config_data, $server_name_start + strlen($server_name_keyword), ($server_name_end - $server_name_start - strlen($server_name_keyword)));
echo "doc root is: " . $document_root;
assuming you've read the file into a variable called $file_contents (by using [man]fread/man, etc.).
This is (and even looks it) overkill; I'm sure regular expression syntax guru's could simplify this for you. Perhaps I could even write some POSIX regular expression, but at the moment I'm very tired, and wanted at least to give you one solution to think about, if no one else supplies you with one.