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 R22-07 is released in version v0.9.0
The first official release of EOOS Automotive that is elaborated for POSIX and WIN32 compatible operating systems and based on interfaces designed for EOOS RT – real time operating system.
Optimization of source code
"The program would have been working if you had held your breath and had not been breathing". It is a good statement, but if a program is working slowly, or it is not flexible, what will we do? Yes, we need to optimize, to debug, and to test it again. Clearly, acceptable compromise between usability and performance is not being found so easily. Just, we should be thinking about it while designing time, and future updating will be easy.
Elements fetching optimization
Results of searching do not cache. This is the main rule which you need to remember. Every time, when we inquire to find elements of tree, the library scans that tree again. Therefore, the searching is faster if a branch is shorter.
The best way is to save a searching result to local variable:
<?php
// It is bad
$node = $document->find('a')->addClass('link');
$node->attr('href', 'baigudin.software');
// It is good
$document->find('a')->addClass('link');
$document->find('a')->attr('href', 'baigudin.software');
?>
We can use a chain of calls:
<?php
// It is good too
$document->find('a')->addClass('link')->attr('href', 'baigudin.software');
?>
We can truncate a tree to "div.article":
<?php
// It is bad
$document->find('div.article h2');
$document->find('div.article a');
// It is good
$node = $document->find('div.article');
$node->find('h2');
$node->find('a');
?>
Indexing of elements
An object of ElementNode class can get a string index, which is called a key, by using key method of the library. The key will be associated with a sequence number of the element in new created list of elements. Thus, we can get an access to the element of a list by its key.
<?php
use DomBuilder\Element as Element;
// Create document
$document = Element::create()
->insert('html')
->insert('head')
->after('body')->root();
// Create empty list
$list = Element::newList();
// Add elements to list
$list->push( Element::create('h1')->html('My header')->key('header') );
$list->push( Element::create('p')->html('My text') )->key('text');
// Add elements of list to document by its keys
$document->find('body')
->insert( $list->get('header') )
->after( $list->get('text') );
// Output document
echo Element::getDocument($document);
?>
We want to mark that you can add a key for an element when you have created it, or you can add a key for a list. If you call key method for ElementList class, the key will be added for last added element to the list.
Note: The library does not monitor that a key is one and only. It is needed in keys only for associating an element in elements list. Therefore, if a list has greater than one element with equal keys, it returns the last added element with that key to its.
We have considered a few simple ways to make applications faster and more intelligible for future supporting. In next article, we will continue to talk about optimizations and tell you about multi-language supporting in range of the library.