fork(5) download
  1. <?php
  2.  
  3. $html = '<a href="#" rel="3" title="масловодоотталкивающая отделка" class="seq">МВО
  4. <div class="tooltip_cont">
  5. <h5>МВО - масловодоотталкивающая отделка</h5>
  6. <p>Благодаря масловодоотталкивающей отделке ткань препятствует проникновению воды и жировых, масляных жидкостей, сохраняя при этом воздухо- (паро- ) проницаемость ( ткань пропускает пары пота). Тестирование проводится нанесением тестирующих жидкостей по методике ф. "3М".</p>
  7. </div>
  8. </a>';
  9.  
  10. $output = array();
  11.  
  12. $doc = new DomDocument();
  13.  
  14. $doc->loadHTML('<?xml encoding="UTF-8">' . $html);
  15.  
  16. /* Корректно обрабатываем UTF-8 */
  17. // dirty fix
  18. foreach ($doc->childNodes as $item)
  19. if ($item->nodeType == XML_PI_NODE)
  20. $doc->removeChild($item); // remove hack
  21. $doc->encoding = 'UTF-8'; // insert proper
  22.  
  23. $urls = $doc->getElementsByTagName('a');
  24.  
  25. foreach ($urls as $url) {
  26.  
  27. if ($url->getAttribute('class') === 'seq') {
  28.  
  29. $childs = $url->getElementsByTagName('*');
  30.  
  31. foreach ($childs as $child) {
  32. $url->removeChild($child);
  33. }
  34.  
  35. $output[] = trim($url->nodeValue);
  36. }
  37.  
  38. }
  39.  
  40. print_r($output);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => МВО
)