PHP DOM Builder API 2.0
- Core\Element\Double
- Core\Element\DoubleBlock
- Core\Element\DoubleInline
- Core\Element\Field
- Core\Element\Root
- Core\Element\Single
- Element\A
- Element\Abbr
- Element\Address
- Element\Area
- Element\Article
- Element\Aside
- Element\Audio
- Element\B
- Element\Base
- Element\Bdi
- Element\Bdo
- Element\Blockquote
- Element\Body
- Element\Br
- Element\Button
- Element\Canvas
- Element\Caption
- Element\Cite
- Element\Code
- Element\Col
- Element\Colgroup
- Element\Command
- Element\Datalist
- Element\Dd
- Element\Del
- Element\Details
- Element\Dfn
- Element\Div
- Element\Dl
- Element\Dt
- Element\Em
- Element\Embed
- Element\Fieldset
- Element\Figcaption
- Element\Figure
- Element\Footer
- Element\Form
- Element\H1
- Element\H2
- Element\H3
- Element\H4
- Element\H5
- Element\H6
- Element\Head
- Element\Header
- Element\Hgroup
- Element\Hr
- Element\Html
- Element\I
- Element\Iframe
- Element\Img
- Element\Input
- Element\Ins
- Element\Kbd
- Element\Keygen
- Element\Label
- Element\Legend
- Element\Li
- Element\Link
- Element\Map
- Element\Mark
- Element\Menu
- Element\Meta
- Element\Meter
- Element\Nav
- Element\Noscript
- Element\Object
- Element\Ol
- Element\Optgroup
- Element\Option
- Element\Output
- Element\P
- Element\Param
- Element\Pre
- Element\Progress
- Element\Q
- Element\Rp
- Element\Rt
- Element\Ruby
- Element\S
- Element\Samp
- Element\Script
- Element\Section
- Element\Select
- Element\Small
- Element\Source
- Element\Span
- Element\Strong
- Element\Style
- Element\Sub
- Element\Summary
- Element\Sup
- Element\Table
- Element\Tbody
- Element\Td
- Element\Textarea
- Element\Tfoot
- Element\Th
- Element\Thead
- Element\Time
- Element\Title
- Element\Tr
- Element\Track
- Element\U
- Element\Ul
- Element\Variable
- Element\Video
- Element\Wbr
EOOS Automotive R23-03 is released in version v0.11.0
The third official release of EOOS Automotive that is qualified for POSIX and WIN32 compatible operating systems and based on interfaces designed for EOOS RT – real time operating system.
Elements finding
Actually, DOM is hierarchical organization and one selecting criterion is not useful sometimes. What should we do if we want to find all A link tags with H2 header parent tags, or all links with HREF attributes which have the same values and are contained in DIV blocks? For this ways, we should use a find method.
Let's take previous article document example, here is it:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PHP DOM Builder test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
</head>
<body>
<div id="content">
<h1>
Header
</h1>
<div class="article" id="id_article">
<h2>
Article 1
</h2>
<p>
<a href="google.com">Text 1</a>
</p>
</div>
<div class="article print">
<h2>
<a href="/article/">Article 2</a>
</h2>
<p>
<a href="baigudin.software">Text 2</a>
</p>
</div>
</div>
<div id="footer">
<p>
© copyright 2016
</p>
</div>
</body>
</html>
And try to find something:
<?php
$document->find('#content'); // Find elements with id=content
$document->find('div#content'); // Find DIV with id=content
$document->find('.article'); // Find elements with class=article
$document->find('div.article'); // Find DIV elements with class=article
$document->find('.article.print'); // Find elements with class=article and print
$document->find('h2'); // Find H2 elements
$document->find('h1, h2'); // Find H1 and H2 elements
?>
As you can see, query string corresponds to CSS Styling Tables. If we remember that DOM is hierarchical organization, we can find like this:
<?php
$document->find('p a'); // Find A elements which are contained in P elements
$document->find('div h2 a'); // Find A elements in H2 elements which in DIV elements
?>
We can find elements by its attributes:
<?php
$document->find('a[href]'); // All links with href attribute
$document->find('a[href=baigudin.software]'); // All links with href=baigudin.software
?>
It is not difficult to understand that the find method finds child elements. So, parents method is exist too. Itfindsdirectparentelements.
<?php
// Find DIV elements with class=article which are parent of A elements
$document->find('a')->parents('div.article');
?>
Let's talk about a filtration. We have a filter and not methods. The filter method selects elements which matched by query, and the not method is contrary to it.
<?php
// Find DIV elements and filter which class=article
$document->find('div')->filter('.article');
// Find A elements and remove which href=baigudin.software
$document->find('a')->not('a[href=baigudin.software]');
?>
In the conclusion, we should say that all find, parents, filter, not methods return ElementList or ElementNode class objects which inherit the Element interface.