Document
class Document extends DOMDocument (View source)
Constants
| XML |
Used with |
| HTML |
Used with |
| JSON |
Used with |
| SIMPLE |
Used with |
| MINIMAL |
Used with |
| COMPLETE |
Used with |
Properties
| protected array | $levels | Used with |
Methods
Create a Document instance
Set level error for exception, set LIBXML_ERR_NONE (or 0 - zero) for disable exceptions.
Convert a array in node elements
Convert DOM to JSON string
Convert DOM to Array
Magic method, return a well-formed XML string
Save file to location
Get namespace attributes from root element or specific element
Load XML from a string
Load XML from a file
Load HTML from a string
Load HTML from a file
Details
void
__construct(string $version = '1.0', string $encoding = 'UTF-8')
Create a Document instance
void
reporting()
Set level error for exception, set LIBXML_ERR_NONE (or 0 - zero) for disable exceptions.
For disable only warnings use like this $dom->reporting(LIBXML_ERR_FATAL, LIBXML_ERR_ERROR)
- 0 - `LIBXML_ERR_NONE` - Disable errors
- 1 - `LIBXML_ERR_WARNING` - Show warnings in DOM
- 2 - `LIBXML_ERR_ERROR` - Show recoverable errors in DOM
- 3 - `LIBXML_ERR_FATAL` - Show DOM fatal errors
void
fromArray(array $data)
Convert a array in node elements
string
toJson(bool $format = Document::MINIMAL, int $options = 0)
Convert DOM to JSON string
array
toArray(int $type = Document::SIMPLE)
Convert DOM to Array
string
__toString()
Magic method, return a well-formed XML string
Example:
``` $xml = new Dom;$xml->fromArray(array( 'foo' => 'bar' ));
echo $xml;
</pre>
void
save(string $path, int $format = Document::XML)
Save file to location
void
getNamespaces(DOMElement $element = null)
Get namespace attributes from root element or specific element
mixed
loadXML(string $source, int $options = 0)
Load XML from a string
mixed
load(string $filename, int $options = 0)
Load XML from a file
mixed
loadHTML(string $source, int $options = 0)
Load HTML from a string
mixed
loadHTMLFile(string $filename, int $options = 0)
Load HTML from a file
DOMNodeList
query(string $selector, DOMNode $context = null)
Use query-selector like CSS, jQuery, querySelectorAll