PHP code example of damijanc / simple-xml

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

    

damijanc / simple-xml example snippets


use damijanc\SimpleXml\Attribute\Node;
use damijanc\SimpleXml\Attribute\Property;

#[Node('books')]
#[Property('type', 'fiction')]
class Books
{
    public array $books;
}

use damijanc\SimpleXml\Attribute\CData;
use damijanc\SimpleXml\Attribute\Node;
use damijanc\SimpleXml\Attribute\Property;

#[Node('book')]
class Book
{
    #[Node('author')]
    #[Property('author', null)]
    public string $author;

    #[Node('title')]
    #[CData()]
    public string $title;

    #[Node('price')]
    public string $price;

}


    #[Node('title')]
    #[Comment('This is a comment')]
    public string $title;

#[Node('book')]
class Book
{
    #[Property('name', null)]
    #[Property('data-link', 'some-dummy-link')]
    public string $author;
} 


#[Node('book')]
class Book
{
    #[Node('author')]
    #[Property('data-link', 'some-dummy-link')]
    public string $author;
}