apsxj / xml
XML Parsing and Response Library
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/apsxj/xml
This package is auto-updated.
Last update: 2025-10-18 02:50:07 UTC
README
XML Parsing and Response Library
Getting Started
- Add the following to your
composer.jsonfile:
"require": { "apsxj/xml": "dev-main" }, "repositories": [ { "type": "git", "url": "https://github.com/apsxj/xml.git" } ]
-
Run
composer install -
Before calling any of the methods, require the vendor autoloader
// For example, from the root directory... require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
- To create an
Responseobject and render it:
<?php // 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);