PHPackages                             wpillar/simple-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wpillar/simple-dom

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wpillar/simple-dom
==================

PHP wrapper for DOMElement.

0231PHP

Since Nov 23Pushed 11y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Simple DOM
==========

[](#simple-dom)

[![Build Status](https://camo.githubusercontent.com/1896b19e5e23ddef1381510c70e21b115b6f256dbb35327d7c84c8abbcb39bb5/68747470733a2f2f7472617669732d63692e6f72672f7770696c6c61722f73696d706c652d646f6d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/wpillar/simple-dom) [![SensioLabsInsight](https://camo.githubusercontent.com/33d8d391f6b9d5bbc7f81e47c7aa97a7d591f652ba9a10dd943e65a141a21e4f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33616132333766312d613564352d346439622d386261352d3930353964383933363137612f6d696e692e706e67)](https://insight.sensiolabs.com/projects/3aa237f1-a5d5-4d9b-8ba5-9059d893617a) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/3dd910b45a7059ae042e3467e1111836fafe011d1857e54c693174a970a9f6e3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7770696c6c61722f73696d706c652d646f6d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wpillar/simple-dom/?branch=master) [![PHP Version](https://camo.githubusercontent.com/7eb8bc8665fe33e59e7aef261307f43cf0afe30b98ca1080a64fbadac3ce8c40/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d7e352e352d3838393242462e737667)](https://camo.githubusercontent.com/7eb8bc8665fe33e59e7aef261307f43cf0afe30b98ca1080a64fbadac3ce8c40/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d7e352e352d3838393242462e737667)

A wrapper for PHP's DOMElement class that provides a nicer API for retrieving data from an element.

Installation
------------

[](#installation)

It can be installed in whichever way you prefer, but we recommend [Composer](https://packagist.org/packages/wpillar/simple-dom).

```
{
    "require": {
        "wpillar/simple-dom": "dev-master"
    }
}
```

Usage
-----

[](#usage)

#### XML

[](#xml)

```
$xml = \Pillar\SimpleDom\Element::xml('

                1477825274

                    From the Cradle
                    Brad Pitt
                    Angelina Jolie

');

foreach ($xml->getElements('Items') as $item) {
    $item->getValue('ASIN'); // 1477825274

    $item->getElement('ItemAtrributes'); // Pillar\SimpleDom\Element
    $item->getElement('ItemAttributes')->getValue('Title'); // 'From the Cradle'
    $item->getElement('ItemAttributes')->getValue('Actor'); // 'Brad Pitt'
    $item->getElement('ItemAttributes')->getValues('Actor'); // ['Brad Pitt', 'Angelina Jolie']
}
```

#### HTML

[](#html)

```
$html = \Pillar\SimpleDom\Element::html('

            My special website

            Welcome to My Special Website!
            Hello World!
            My name is Will

');

$html->getElement('head')->getValue('title'); // 'My special website'
$html->getElement('body')->getValue('h1'); // 'Welcome to My Special Website'
$html->getElement('body')->getValue('p'); // 'Hello World!'
$html->getElement('body')->getValues('p'); // ['Hello World!', 'My name is Will']
$html->getElements('p'); // Pillar\SimpleDom\Element[]
```

Contributing
------------

[](#contributing)

I prefer to use the [GitHub Flow](https://guides.github.com/introduction/flow/index.html) for working. So please submit a PR with your proposed changes stating the case for adding the changes with any documentation and tests that are appropriate.

This library aims to adhere to [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/) and [PSR-4](http://www.php-fig.org/psr/psr-4/) standards so please make sure contributions adhere to those standards too. Also, if you spot any existing violations of those standards, PRs to fix them are most welcome.

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2014 Will Pillar

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3bdf6f679a68eed76e804bd410aead3b69da0c68484d7422a4129c18f45ab10?d=identicon)[wpillar](/maintainers/wpillar)

---

Top Contributors

[![wpillar](https://avatars.githubusercontent.com/u/188514?v=4)](https://github.com/wpillar "wpillar (6 commits)")

### Embed Badge

![Health badge](/badges/wpillar-simple-dom/health.svg)

```
[![Health](https://phpackages.com/badges/wpillar-simple-dom/health.svg)](https://phpackages.com/packages/wpillar-simple-dom)
```

###  Alternatives

[krakjoe/pthreads-polyfill

A polyfill for pthreads

80134.9k1](/packages/krakjoe-pthreads-polyfill)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
