fork(2) download
  1. <?php
  2.  
  3. // html
  4. $content = '<!DOCTYPE html>
  5. <html lang="en" dir="ltr" xmlns="http://w...content-available-to-author-only...3.org/1999/xhtml">
  6. <head>
  7. <meta charset="utf-8" />
  8. <title>Welcome to WPИ-XM Serverpack!</title>
  9. <link rel="icon" href="tools/webinterface/favicon.ico" type="image/x-icon" />
  10. <meta http-equiv="refresh" content="3; URL=tools/webinterface/">
  11. </head>
  12. <body bgcolor="E7E7E7" text="333333">
  13. <div id="container">
  14. <div id="content">
  15. <h1>Welcome to the WPИ-XM server stack!</h1>
  16. </div>
  17. <strong>You should be redirected to the administration interface of WPN-XM in 5 seconds.</strong>
  18. <br>
  19. Click <a href="tools/webinterface/">here</a> for immediate redirection.
  20. </div>
  21. </body>
  22. </html>';
  23.  
  24. $doc = new DOMDocument();
  25. $doc->loadHTML($content);
  26.  
  27. $xpath = new DOMXpath($doc);
  28. $nodes = $xpath->query('//*');
  29.  
  30. // ---- my answer ----
  31.  
  32. foreach ($nodes as $node) {
  33.  
  34. // skip html and body
  35. if($node->nodeName === 'html' or $node->nodeName === 'body') {
  36. continue;
  37. }
  38.  
  39. // insert everything else
  40. $names[] = $node->nodeName;
  41. }
  42.  
  43. $css = 'color:red;';
  44.  
  45. echo join(', ', array_unique($names)) . " {\n" . $css . "\n}\n";
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
head, meta, title, link, div, h1, strong, br, a {
color:red;
}