Ricerca Tag in pagine HTML

  • Creatore Discussione Creatore Discussione gpessa
  • Data di inizio Data di inizio

gpessa

Nuovo Utente
2 Ago 2008
6
0
0
Salve devo riuscire a scovare tutti i tag html che contraddistinguono un frame.
Quindi se ho una pagina con frame vorrei trovare tutti i frame DTD con i loro nomi e attributi.
Esempio, se avessi un xhtml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
<title> Titolo della mia pagina Web con frames</title>
</head>
<frameset cols="130, *">
<frame name="menu" id="menu" src="menu.html" />
<frame name="princ" id="princ" src="principale.html" />
<noframes>
<body>
<p> Testo visto da chi non supporta i frames</p>
</body>
</noframes>
</frameset>
</html>

Vorrei avere come risultati:

<frame name="menu" id="menu" src="menu.html" />

e

<frame name="princ" id="princ" src="principale.html" />

Si può fare? Come? Suggerimenti...


Grazie in anticipo
 
Direi che così potrebbe andare bene:

PHP:
$testo1 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
<title> Titolo della mia pagina Web con frames</title>
</head>
<frameset cols="130, *">
<frame name="menu" id="menu" src="menu.html" />
<frame name="princ" id="princ" src="principale.html" />
<noframes>
<body>
<p> Testo visto da chi non supporta i frames</p>
</body>
</noframes>
</frameset>
</html>';

$pattern = '/< *frame [^>]+>/';

preg_match_all($pattern, $testo1, $matches);


foreach ($matches[0] as $name)  {
  echo "<b>Frame: </b> " . htmlspecialchars($name) . "<br/>";
}
 

Discussioni simili

M
Risposte
0
Visite
1K
HTML e CSS
Membro cancellato 26246
M