(PHP 5, PHP 7, PHP 8)
tidyNode::isText — Comprueba si un nodo representa un texto (no HTML)
Indica si un nodo representa sólo texto (sin nada de HTML).
Esta función no contiene ningún parámetro.
Ejemplo #1 Extraer el texto de un documento HTML
<?php
$html = <<< HTML
<html><head>
<?php echo '<title>titulo</title>'; ?>
<#
  /* código JSTE */
  alert('Hola Mundo');
#>
</head>
<body>
<?php
  // código PHP
  echo 'hola mundo!';
?>
<%
  /* código ASP */
  response.write("Hola Mundo!")
%>
<!-- Comentarios -->
Hola Mundo
</body></html>
Fuera del HTML
HTML;
$tidy = tidy_parse_string($html);
$num = 0;
get_nodes($tidy->html());
function get_nodes($node) {
    // Verifica si el nodo actual es del tipo requerido
    if($node->isText()) {
        echo "\n\n# text node #" . ++$GLOBALS['num'] . "\n";
        echo $node->value;
    }
    // Verifica si el nodo actual tiene hijos
    if($node->hasChildren()) {
        foreach($node->child as $child) {
            get_nodes($child);
        }
    }
}
?>El ejemplo anterior mostrará:
# text node #1 Hola Mundo # text node #2 Fuera del HTML
