PHP code example of ls-a / xml-utils

1. Go to this page and download the library: Download ls-a/xml-utils 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/ */

    

ls-a / xml-utils example snippets



// A footnote tag
class FootnoteTag extends Tag implements HasDefinition
{
    // This method allows you to customize tag name, if you wish to
    public function getTagName(): string
    {
        return 'footnote';
    }

    // This method allows you to define a strict constraint on this tag
    public function asDefinition(): Definition
    {
        return (new Definition())
            // Allowed elements in this tag: `<inline>` and `<footnote-body>`
            ->sequence(new Sequence(
                new Element(Inline::class),
                new Element(FootnoteBody::class),
            ))
            // Allowed attributes
            ->allows([
                // An attribute group
                AccessibilityProperties::class,
                // A property
                Id::class,
                // A typed attribute
                new TypedAttribute('margin', MarginType::class)
            ])
            // Inherited attributes
            ->inheritables([
                // Another attribute group
                InheritedProperties::class,
            ]);
    }
}