The value attribute of any given node represents the value of the entire branch

<?php
    tidy_parse_file
('test.html');
    
tidy_clean_repair();
    
    
$head tidy_get_head();
    
$html tidy_get_html();
    
    
$head htmlentities($head->value);
    
$html htmlentities($html->value);
    echo 
"<PRE>Head: $head\n\nHTML: $html</PRE>";
?>
Result:
Head: <head>
<title>Hello, World!</title>
</head>

HTML: <html>
<head>
<title>Hello, World!</title>
</head>
<body bgcolor="#ffffff">
<b>A simple HTML document</b>
</body>
</html>