Skip to content

Commit

Permalink
Update the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Imangazaliev committed May 8, 2022
1 parent 18ed017 commit acb5f1f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
21 changes: 16 additions & 5 deletions README-RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
[![Latest Stable Version](https://poser.pugx.org/imangazaliev/didom/v/stable)](https://packagist.org/packages/imangazaliev/didom)
[![License](https://poser.pugx.org/imangazaliev/didom/license)](https://packagist.org/packages/imangazaliev/didom)

[English version](README.md)

DiDOM - простая и быстрая библиотека для парсинга HTML.

- [English version](README.md)
- [Документация для версии 1.x](https://github.com/Imangazaliev/DiDOM/blob/98d411741d598b0b74bb38e215d99c1cdb0d532d/README-RU.md). Чтобы обновится с версии 1.x, пожалуйста просмотрите [историю изменений](CHANGELOG.md).

## Содержание

- [Установка](#Установка)
Expand Down Expand Up @@ -307,10 +308,20 @@ $element->find('> a');
$element->setInnerHtml('<a href="#">Foo</a>');
```

### Изменение значения
### Изменение XML

```php
$element->setInnerXml(' Foo <span>Bar</span><!-- Baz --><![CDATA[
<root>Hello world!</root>
]]>');
```

### Изменение значения (как простой текст)

```php
$element->setValue('Foo');
// будет закодирован в HTML-сущность как при вызове htmlentities()
$element->setValue('<a href="#">Foo</a>');
```

## Вывод содержимого
Expand Down Expand Up @@ -471,7 +482,7 @@ $element = Element::createBySelector('div.block', 'Foo', [
## Получение названия элемента

```php
$element->tag;
$element->tagName();
```

## Получение родительского элемента
Expand Down Expand Up @@ -586,7 +597,7 @@ $document = new Document($html);

$element = $document->first('input[name=email]');

$document2 = $element->getDocument();
$document2 = $element->ownerDocument();

// bool(true)
var_dump($document->is($document2));
Expand Down
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
[![Latest Stable Version](https://poser.pugx.org/imangazaliev/didom/v/stable)](https://packagist.org/packages/imangazaliev/didom)
[![License](https://poser.pugx.org/imangazaliev/didom/license)](https://packagist.org/packages/imangazaliev/didom)

[README на русском](README-RU.md)

DiDOM - simple and fast HTML parser.

- [README на русском](README-RU.md)
- [DiDOM 1.x documentation](https://github.com/Imangazaliev/DiDOM/blob/98d411741d598b0b74bb38e215d99c1cdb0d532d/README.md). To upgrade from 1.x please checkout the [changelog](CHANGELOG.md).

## Contents

- [Installation](#installation)
Expand All @@ -18,6 +19,7 @@ DiDOM - simple and fast HTML parser.
- [Verify if element exists](#verify-if-element-exists)
- [Search in element](#search-in-element)
- [Supported selectors](#supported-selectors)
- [Changing content](#changing-content)
- [Output](#output)
- [Working with elements](#working-with-elements)
- [Creating a new element](#creating-a-new-element)
Expand Down Expand Up @@ -256,6 +258,30 @@ $document->find('a.foo::text');
$document->find('a.bar::attr(href|title)');
```

## Changing content

### Change inner HTML

```php
$element->setInnerHtml('<a href="#">Foo</a>');
```

### Change inner XML

```php
$element->setInnerXml(' Foo <span>Bar</span><!-- Baz --><![CDATA[
<root>Hello world!</root>
]]>');
```

### Change value (as plain text)

```php
$element->setValue('Foo');
// will be encoded like using htmlentities()
$element->setValue('<a href="#">Foo</a>');
```

## Output

### Getting HTML
Expand Down Expand Up @@ -360,7 +386,7 @@ $element = $document->createElement('span', 'Hello');
## Getting the name of an element

```php
$element->tag;
$element->tagName();
```

## Getting parent element
Expand Down Expand Up @@ -410,14 +436,14 @@ var_dump($div->lastChild()->text());
var_dump($div->children());
```

## Getting document
## Getting owner document

```php
$document = new Document($html);

$element = $document->find('input[name=email]')[0];

$document2 = $element->getDocument();
$document2 = $element->ownerDocument();

// bool(true)
var_dump($document->is($document2));
Expand Down

0 comments on commit acb5f1f

Please sign in to comment.