PHP code example of apsxj / xml

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

    

apsxj / xml example snippets


// For example, from the root directory...



// unwrap classes from the apsxj\xml namespace
use apsxj\xml\Node;
use apsxj\xml\Doc;
use apsxj\xml\Response;

// Create the doctype declaration node
$doctype = Node::element(
  '!DOCTYPE',
  array(
    'html' => 'html'
  )
);

// Create the HTML node
$html = Node::element(
  'html',
  array(
    'lang' => 'en',
    'class' => 'h-100'
  ),
  array(
    Node::text('<head><title>It works!</title></head><body><h1>It works!</h1></body>')
  )
);

// Create the Document
$doc = new Doc($doctype, $html);

// Pass the document to a new Response object
$response = new Response($doc);

// Render the response
$response->render(200);