PHP code example of drmad / semeele

1. Go to this page and download the library: Download drmad/semeele 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/ */

    

drmad / semeele example snippets


$xml = new Drmad\Semeele\Document('html');
$xml->child('head')
    ->add('title', 'An XHTML')
    ->add('meta', ['charset' => 'utf-8'])
    ->parent()
->child('body')
    ->add('h1', 'An XHTML')
    ->add('p', 'This is a XML-valid HTML. Yay!')
;

echo $xml->getXML();

$xml = new Drmad\Semeele\Node('ext:UBLExtension');
$xml->child('ext:ExtensionContent')
    ->child('ds:Signature', ['Id' => 'Signature'])->save($s) // Save this node for later
        ->child('ds:SignedInfo')
            ->add('ds:CanonicalizationMethod',
                ['Algorithm'=>'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'])
            ->add('ds:SignatureMethod',
                ['Algorithm'=>'http://www.w3.org/2000/09/xmldsig#rsa-sha1'])
            ->child('ds:Reference', ['URI'=>''])
                ->child('ds:Transforms')
                    ->add('ds:Transform', ['Algorithm'=>'http://www.w3.org/2000/09/xmldsig#enveloped-signature'])
                    ->parent()
                ->add('ds:DigestMethod', ['Algorithm'=>'http://www.w3.org/2000/09/xmldsig#sha1'])
                ->add('ds:DigestValue')
;
        $s->add('ds:SignatureValue')    // Using the saved node
        ->child('ds:KeyInfo')
            ->child('ds:X509Data')
                ->add('ds:X509SubjectName')
                ->add('ds:X509Certificate')
;
echo $xml;

const SEMEELE_PATH = './semeele-master';

spl_autoload_register(function($class) {
    if (substr($class, 0, 13) == 'Drmad\\Semeele') {
        $base_name = substr($class, strrpos($class, '\\') + 1);
        $file_name = SEMEELE_PATH . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $base_name . '.php';
        if (file_exists($file_name)) {
            

$xml = new Drmad\Semeele\Node('test');
$xml->add('without_cdata', 'Love this song from <strong>KC & The Sunshine</strong>')
    ->add('with_cdata', new Drmad\Semeele\Cdata('Love that song from <strong>KC & The Sunshine</strong>'))
;
echo $xml;