Орла
Области
Компаний
Пользователи
Галерея
Фиксированные новости
Орла
Отзывы о фирмах
Тарифы
Пользователи
Области
Банкоматы
Торговые точки
Доска объявлений
Курсы валют
Скидки
организации Орла
организации области
товары
сайты
сайты Орел
Данные
Разделы
Поиск
Поиск запросы
Статистика
Показы каталога организаций
Статистика клиенты
Пользователи
Сайты
Управление сайтом
Анкета
Аптеки
Афиша
Афиша новая
Баннеры
Бизнес >
Викторина
Голосование
Гость на сайте
Истории
Календарь событий
Каталоги >
Конкурс красоты
Конкурс аудио
Консультации
Меню
Новое на сайте
Новости >
Организации >
Программа ТВ
Публикации
Разделы сайта
Рассылка
Рестораны
Секрет фирмы >
Сервисы >
Ссылки
Тесты
Файловый менеджер
Форум
Фотогалерея
Обратная связь
Недвижимость
Новый год
Тексты
Пользователи
Юридический рейтинг
Отзывы на товары
Бан пользователей
Жалобы
Новые тесты
Коронавирус
Файловый менеджер
Имя файла
finding-html-elements.md
Содержимое
--- title: Finding HTML Elements --- # Finding elements by tag name ```php // Find all anchors, returns a array of element objects $ret = $html->find('a'); // Find all anchors and images, returns an array of element objects $ret = $html->find('a, img'); // Find (N)th anchor, returns element object or null if not found (zero based) $ret = $html->find('a', 0); // Find last anchor, returns element object or null if not found (zero based) $ret = $html->find('a', -1); ``` # Finding elements by class name or id ```php // Find all element which id=foo $ret = $html->find('#foo'); // Find all element which class=foo $ret = $html->find('.foo'); ``` # Finding elements by attribute ```php // Find all <div> with the id attribute $ret = $html->find('div[id]'); // Find all <div> which attribute id=foo $ret = $html->find('div[id=foo]'); // Find all anchors and images with the "title" attribute $ret = $html->find('a[title], img[title]'); // Find all element has attribute id $ret = $html->find('*[id]'); ``` ## Attribute filters Supports these operators in attribute selectors: Filter | Description | -----|-----------| `[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. # Finding descendants ```php // Find all <li> in <ul> $es = $html->find('ul li'); // Find Nested <div> tags $es = $html->find('div div div'); // Find all <td> in <table> 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]'); ``` # Finding nested elements ```php // Find all <li> in <ul> foreach($html->find('ul') as $ul) { foreach($ul->find('li') as $li) { // do something... } } // Find first <li> in first <ul> $e = $html->find('ul', 0)->find('li', 0); ``` # Finding text blocks and comments ```php // Find all text blocks $es = $html->find('text'); // Find all comment (<!--...-->) blocks $es = $html->find('comment'); ```
/busines/parser/manual/docs/manual/
Имя
Дата
Размер
..
2020-01-15
accessing-element-attributes.md
2020-01-15
1 кб.
adding-nodes.md
2020-01-15
3 кб.
creating-dom-objects.md
2020-01-15
615 байт
customizing-parsing-behavior.md
2020-01-15
398 байт
finding-html-elements.md
2020-01-15
3 кб.
saving-dom-objects.md
2020-01-15
324 байт
traversing-dom-tree.md
2020-01-15
1 кб.
/busines/parser/manual/docs/manual
Загрузить файлы
Файл 1
Файл 2
Файл 3