PHP code example of 8fold / php-xml-builder

1. Go to this page and download the library: Download 8fold/php-xml-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

8fold / php-xml-builder example snippets


use Eightfold\XMLBuilder\Document;
use Eightfold\XMLBuilder\Element;
use Eightfold\XMLBuilder\Cdata;

echo Document::create('root',
  Element::create('child',
    Element::create('grandchild')->omitEndTag()->props('name Xavier'),
    Cdata::create('Hello, my name is Xavier!')
  )
);

use Eightfold\XMLBuilder\Document;
use Eightfold\XMLBuilder\Element;
use Eightfold\XMLBuilder\Cdata;

echo Document::root(
  Element::child(
    Element::grandchild()->omitEndTag()->props('name Xavier'),
    Cdata::create('Hello, my name is Xavier!')
  )
);

// output: Same as previous example.

use Eightfold\XMLBuilder\Document;
use Eightfold\XMLBuilder\Element;
use Eightfold\XMLBuilder\Cdata;

echo Document::create(
  'root',
  Comment::create('comment'),
  Element::create('tag')->omitEndTag()
);