Baigudin Software avatar
Baigudin Software logo
ru region
en region

PHP DOM Builder API 2.0

EOOS Automotive R22-08 is released in version v0.10.0

The second 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.

Beginning of work

So, we have included the library and set it. Now we can create a basic HTML document.

use DomBuilder\Element as Element
// Create document 
$document Element::create(); 
// Add main tags to document 
$node $document->insert('html'); 
// Output document
echo Element::getDocument($document);

The result of this example is here:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xml:lang="en" lang="en">

Every HTML document can be represented as a tree list of elements . In our example, we have created a root element of document and linked some elements to it. All methods for creating elements, such as create, insert, after,and before, create a new element and return a reference to it. That is why we could rewrite our example like here:

use DomBuilder\Element as Element
// Create tree list 
$root Element::create('html')
// Output document 
echo Element::getDocument($root);

If we want to get a correct document, we need to give getDocument method a root element of document. It is possible by using root method, which travels all DOM tree and returns a reference to a root element.

To the previous article

To the articles list

To the next article