PHPackages                             kuria/dom - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kuria/dom

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

kuria/dom
=========

Wrappers around the PHP DOM classes

v3.1.1(8y ago)616.8k↓33.3%MITPHPPHP &gt;=7.1

Since Dec 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kuria/dom)[ Packagist](https://packagist.org/packages/kuria/dom)[ RSS](/packages/kuria-dom/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (11)Used By (0)

DOM
===

[](#dom)

Wrappers around the [PHP DOM classes](http://php.net/manual/en/book.dom.php)that handle the common DOM extension pitfalls.

[![https://travis-ci.com/kuria/dom.svg?branch=master](https://camo.githubusercontent.com/be0dc1e01962fa3165c5381ded9155dc1075bc4919e50493b007cf1190858b10/68747470733a2f2f7472617669732d63692e636f6d2f6b757269612f646f6d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/kuria/dom)Contents

- [Features](#features)
- [Requirements](#requirements)
- [Container methods](#container-methods)
    - [Loading documents](#loading-documents)
    - [Getting or changing document encoding](#getting-or-changing-document-encoding)
    - [Saving documents](#saving-documents)
    - [Getting DOM instances](#getting-dom-instances)
    - [Running XPath queries](#running-xpath-queries)
    - [Escaping strings](#escaping-strings)
    - [DOM manipulation and traversal helpers](#dom-manipulation-and-traversal-helpers)
- [Usage examples](#usage-examples)
    - [HTML documents](#html-documents)
        - [Loading an existing document](#loading-an-existing-document)
        - [Creating an new document](#creating-an-new-document)
    - [HTML fragments](#html-fragments)
        - [Loading an existing fragment](#loading-an-existing-fragment)
        - [Creating a new fragment](#creating-a-new-fragment)
    - [XML documents](#xml-documents)
        - [Loading an existing document](#id1)
        - [Creating a new document](#creating-a-new-document)
        - [Handling XML namespaces in XPath queries](#handling-xml-namespaces-in-xpath-queries)
    - [XML fragments](#xml-fragments)
        - [Loading an existing fragment](#id2)
        - [Creating a new fragment](#id3)

[Features](#id4)
----------------

[](#features)

- HTML documents
    - encoding sniffing
    - optional tidy support (automatically fix broken HTML)
- HTML fragments
- XML documents
- XML fragments
- XPath queries
- creating documents from scratch
- optional error suppression
- helper methods for common tasks, such as:
    - querying multiple or a single node
    - checking for containment
    - removing a node
    - removing all nodes from a list
    - prepending a child node
    - inserting a node after another node
    - fetching `` and `` elements (HTML)
    - fetching root elements (XML)

[Requirements](#id5)
--------------------

[](#requirements)

- PHP 7.1+

[Container methods](#id6)
-------------------------

[](#container-methods)

These methods are shared by both HTML and XML containers.

### [Loading documents](#id7)

[](#loading-documents)

```
