Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 29 revisions

Category:Libraries

[h3]DOMLib[/h3]

This library was built to ease the use of the PHP DOM functions. I found it too tedious to always be writing this: [CODE] $this->doc = new DOMDocument ('1.0', 'iso-8859-1');

$this->doc->preserveWhiteSpace    = false;

$this->doc->formatOutput          = true;



$root       = $this->doc->createElement('root');

$this->doc->appendChild($root);

[/CODE]

An example of the above using this library would be: [CODE] // Must load the library properly $doc = $this->domlib->domNew(false); // Creates new DOMDocument object. $this->domlib->domRoot('root', $doc); // Creates root element and appends to the document. [/CODE]

The XML version, encoding, and formatOutput are set as constants.

-- XML_VERSION = '1.0'; -- XML_ENCODING = 'iso-8859-1'; -- FORMAT_OUTPUT = 'TRUE';

This library includes pretty much all of the most common functions - I may include full DOM functionality in the near future.

You can create these types of nodes with the library:

-- Standard XML elements -- Element text (must be appended [b]TO[/b] an element) -- Element attributes (must be appended [b]TO[/b] an element) -- XML comments <!-- comment --> -- CDATA sections [[CDATA[ -- Transforms with XSLT and optional parameters -- Output DOMDocument tree as an XML string to browser -- Output DOMDocument tree as a file -- Load an XML document for processing

Clone this wiki locally