PHPackages                             vzeufd/php-fast-simple-html-dom-parser-xxx - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. vzeufd/php-fast-simple-html-dom-parser-xxx

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

vzeufd/php-fast-simple-html-dom-parser-xxx
==========================================

PHP Fast Simple HTML DOM parser.

1.41(5y ago)08MITPHPPHP &gt;=5.6

Since Feb 3Pushed 5y agoCompare

[ Source](https://github.com/vzeufd/PHP-Fast-Simple-HTML-DOM-Parser-xxx)[ Packagist](https://packagist.org/packages/vzeufd/php-fast-simple-html-dom-parser-xxx)[ RSS](/packages/vzeufd-php-fast-simple-html-dom-parser-xxx/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (10)Used By (0)

PHP Fast Simple HTML DOM Parser (fork)
======================================

[](#php-fast-simple-html-dom-parser-fork)

PHP Fast Simple HTML DOM Parser - fast and low mamory usage HTML DOM Parser with syntax like PHP Simple HTML DOM Parser

Установка
---------

[](#установка)

Для установки выполните команду:

```
composer require (fork)/php-fast-simple-html-dom-parser

```

Быстрый старт
-------------

[](#быстрый-старт)

```
require_once "vendor/autoload.php";
use FastSimpleHTMLDom\Document;

// Create DOM from URL
$html = Document::file_get_html('https://habrahabr.ru/interesting/');

// Find all post blocks
$post = [];
foreach($html->find('div.post') as $post) {
    $item['title']   = $post->find('h1.title', 0)->plaintext;
    $item['hubs']    = $post->find('div.hubs', 0)->plaintext;
    $item['content'] = $post->find('div.content', 0)->plaintext;
    $post[] = $item;
}

print_r($post);
```

Как создать HTML DOM объект
---------------------------

[](#как-создать-html-dom-объект)

```
// Create a DOM object from a string
$html = new Document('Hello!');

// Create a DOM object from a string
$html = new Document();
$html->loadHtml('Hello!');

// Create a DOM object from a HTML file
$html = new Document();
$html->loadHtmlFile('test.htm');

// Create a DOM object from a URL
$html = new Document(file_get_contents('https://habrahabr.ru/interesting/'));
```

Как искать HTML DOM элементы?
-----------------------------

[](#как-искать-html-dom-элементы)

### Основа

[](#основа)

```
// Find all anchors, returns a array of element objects
$ret = $html->find('a');

// Find (N)th anchor, returns element object or null if not found (zero based)
$ret = $html->find('a', 0);

// Find lastest anchor, returns element object or null if not found (zero based)
$ret = $html->find('a', -1);

// Find all  with the id attribute
$ret = $html->find('div[id]');

// Find all  which attribute id=foo
$ret = $html->find('div[id=foo]');
```

### Часто используемое

[](#часто-используемое)

```
// Find all element which id=foo
$ret = $html->find('#foo');

// Find all element which class=foo
$ret = $html->find('.foo');

// Find all element has attribute id
$ret = $html->find('*[id]');

// Find all anchors and images
$ret = $html->find('a, img');

// Find all anchors and images with the "title" attribute
$ret = $html->find('a[title], img[title]');
```

### Слекторы потомков

[](#слекторы-потомков)

```
// Find all  in
$es = $html->find('ul li');

// Find Nested  tags
$es = $html->find('div div div');

// Find all  in  which class=hello
$es = $html->find('table.hello td');

// Find all td tags with attribite align=center in table tags
$es = $html->find('table td[align=center]');
```

### Вложенные селекторы

[](#вложенные-селекторы)

```
// Find all  in
foreach($html->find('ul') as $ul)
{
       foreach($ul->find('li') as $li)
       {
             // do something...
       }
}

// Find first  in first
$e = $html->find('ul', 0)->find('li', 0);
```

### Фильтр атрибутов

[](#фильтр-атрибутов)

FilterDescription\[attribute\]Matches elements that have the specified attribute.\[!attribute\]Matches elements that don't have the specified attribute.\[attribute=value\]Matches elements that have the specified attribute with a certain value.\[attribute!=value\]Matches elements that don't have the specified attribute with a certain value.\[attribute^=value\]Matches elements that have the specified attribute and it starts with a certain value.\[attribute$=value\]Matches elements that have the specified attribute and it ends with a certain value.\[attribute\*=value\]Matches elements that have the specified attribute and it contains a certain value.### Текст, комментарии

[](#текст-комментарии)

```
// Find all text blocks
$es = $html->find('text');

// Find all comment () blocks
$es = $html->find('comment');
```

Доступ к атрибутам
------------------

[](#доступ-к-атрибутам)

### Получение, установка и удаление атрибутов

[](#получение-установка-и-удаление-атрибутов)

```
// Get a attribute ( If the attribute is non-value attribute (eg. checked, selected...), it will returns true or false)
$value = $e->href;

// Set a attribute(If the attribute is non-value attribute (eg. checked, selected...), set it's value as true or false)
$e->href = 'my link';

// Remove a attribute, set it's value as null!
$e->href = null;

// Determine whether a attribute exist?
if(isset($e->href))
        echo 'href exist!';
```

### "Магические" атрибуты

[](#магические-атрибуты)

```
// Example
$html = str_get_html('foo bar');
$e = $html->find('div', 0);

echo $e->tag; // Returns: "div"
echo $e->outertext; // Returns: "foo bar"
echo $e->innertext; // Returns: "foo bar"
echo $e->plaintext; // Returns: "foo bar"
```

Attribute NameUsage$e-&gt;tagRead or write the tag name of element.$e-&gt;outertextRead or write the outer HTML text of element.$e-&gt;innertextRead or write the inner HTML text of element.$e-&gt;plaintextRead or write the plain text of element.### Трюки

[](#трюки)

```
// Extract contents from HTML
echo $html->plaintext;

// Wrap a element
$e->outertext = '' . $e->outertext . '';

// Remove a element, set it's outertext as an empty string
$e->outertext = '';

// Append a element
$e->outertext = $e->outertext . 'foo';

// Insert a element
$e->outertext = 'foo' . $e->outertext;
```

Прогон по DOM-дереву
--------------------

[](#прогон-по-dom-дереву)

```
// If you are not so familiar with HTML DOM, check this link to learn more...

// Example
echo $html->find('#div1', 0)->children(1)->children(1)->children(2)->id;
// or
echo $html->getElementById('div1')->childNodes(1)->childNodes(1)->childNodes(2)->getAttribute('id');
```

MethodDescription`mixed` $e-&gt;children(\[int $index\])Returns the Nth child object if index is set, otherwise return an array of children.`Element` $e-&gt;parent()Returns the parent of element.`Element` $e-&gt;first\_child()Returns the first child of element, or null if not found.`Element` $e-&gt;last\_child()Returns the last child of element, or null if not found.`Element` $e-&gt;next\_sibling()Returns the next sibling of element, or null if not found.`Element` $e-&gt;prev\_sibling()Returns the previous sibling of element, or null if not found.API-справочник
--------------

[](#api-справочник)

### Методы и свойства DOM

[](#методы-и-свойства-dom)

NameDescription`void` \_\_construct(\[stringElement $html\])`string` plaintextReturns the contents extracted from HTML.`mixed` find (string $selector \[, int $index\])Find elements by the CSS selector. Returns the Nth element object if index is set, otherwise return an array of object.### Методы и свойства элементов

[](#методы-и-свойства-элементов)

NameDescription`string` \[attribute\]Read or write element's attribure value.`string` tagRead or write the tag name of element.`string` outertextRead or write the outer HTML text of element.`string` innertextRead or write the inner HTML text of element.`string` plaintextRead or write the plain text of element.`mixed` find (string $selector \[, int $index\])Find children by the CSS selector. Returns the Nth element object if index is set, otherwise, return an array of object.### Прогон по дереву DOM

[](#прогон-по-дереву-dom)

NameDescription`mixed` $e-&gt;children(\[int $index\])Returns the Nth child object if index is set, otherwise return an array of children.`element` $e-&gt;parent()Returns the parent of element.`element` $e-&gt;first\_child()Returns the first child of element, or null if not found.`element` $e-&gt;last\_child()Returns the last child of element, or null if not found.`element` $e-&gt;next\_sibling()Returns the next sibling of element, or null if not found.`element` $e-&gt;prev\_sibling()Returns the previous sibling of element, or null if not found.### camelCase эквиваленты

[](#camelcase-эквиваленты)

```
string $e->getAttribute($name)
string $e->attribute

void $e->setAttribute($name, $value)
void $value = $e->attribute

bool $e->hasAttribute($name)
bool isset($e->attribute)

void $e->removeAttribute($name)
void $e->attribute = null

element $e->getElementById($id)
mixed $e->find("#$id", 0)

mixed $e->getElementsById($id [,$index])
mixed $e->find("#$id" [, int $index])

element $e->getElementByTagName($name)
mixed $e->find($name, 0)

mixed $e->getElementsByTagName($name [, $index])
mixed $e->find($name [, int $index])

element $e->parentNode()
element $e->parent()

mixed $e->childNodes([$index])
mixed $e->children([int $index])

element $e->firstChild()
element $e->first_child()

element $e->lastChild()
element $e->last_child()

element $e->nextSibling()
element $e->next_sibling()

element $e->previousSibling()
element $e->prev_sibling()
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 86.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~210 days

Recently: every ~417 days

Total

9

Last Release

2071d ago

Major Versions

0.9.2 → 1.02016-02-06

PHP version history (3 changes)0.9PHP &gt;=5.5.9

1.1PHP &gt;=5.4

1.3PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f33f931358247a9b3767390498c8eb312deee958e6fefea3b2b5a9834295976?d=identicon)[mail3maxim](/maintainers/mail3maxim)

---

Top Contributors

[![dimabdc](https://avatars.githubusercontent.com/u/4645687?v=4)](https://github.com/dimabdc "dimabdc (44 commits)")[![vzeufd](https://avatars.githubusercontent.com/u/9444809?v=4)](https://github.com/vzeufd "vzeufd (7 commits)")

---

Tags

parserhtmlparse

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vzeufd-php-fast-simple-html-dom-parser-xxx/health.svg)

```
[![Health](https://phpackages.com/badges/vzeufd-php-fast-simple-html-dom-parser-xxx/health.svg)](https://phpackages.com/packages/vzeufd-php-fast-simple-html-dom-parser-xxx)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[paquettg/php-html-parser

An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.

2.4k7.9M123](/packages/paquettg-php-html-parser)[sunra/php-simple-html-dom-parser

Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.

1.3k9.4M62](/packages/sunra-php-simple-html-dom-parser)[imangazaliev/didom

Simple and fast HTML parser

2.2k2.3M64](/packages/imangazaliev-didom)[scotteh/php-dom-wrapper

Simple DOM wrapper to select nodes using either CSS or XPath expressions and manipulate results quickly and easily.

1471.9M10](/packages/scotteh-php-dom-wrapper)[olamedia/nokogiri

HTML Parser

23176.3k3](/packages/olamedia-nokogiri)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
