PHP code example of maniaplanet / manialib-xml

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

    

maniaplanet / manialib-xml example snippets




use ManiaLib\XML\Node;
use ManiaLib\XML\Rendering\Renderer;

::create()
	->setNodeName('rootElement')
	->setAttribute('rootAttrivute', '1.0');

// This is one way to append child, ie. "append this element to its parent"
Node::create()
	->setNodeName('someElement')
	->setAttribute('someAttribute', 'foo')
	->setAttribute('otherAttribute', 'bar')
	->setNodeValue('Hello world')
	->appendTo($root);

// This is another way, ie. "appends a child to this element"
$node = Node::create()->setNodeName('anotherOne');
$root->appendChild($node);

// Let's render the tree
$renderer = new Renderer();
$renderer->setRoot($root);
echo $renderer->getXML();