PHPackages                             tomzx/html-parser - 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. tomzx/html-parser

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

tomzx/html-parser
=================

An HTML parser written in PHP

v0.1.0(10y ago)2121[2 issues](https://github.com/tomzx/html-parser/issues)MITPHPPHP &gt;=5.4.0

Since Jan 24Pushed 10y ago1 watchersCompare

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

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

HTML parser
===========

[](#html-parser)

[![License](https://camo.githubusercontent.com/86ecce3c299df7cb1e211e2ed87186c8f258b5fe8fe1346f78bda86ecf6a8e5f/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7a782f68746d6c2d7061727365722f6c6963656e73652e737667)](https://packagist.org/packages/tomzx/html-parser)[![Latest Stable Version](https://camo.githubusercontent.com/33dc4606662dd3c07cc705bd8292ef572d35fd622da7676c43269b693672c553/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7a782f68746d6c2d7061727365722f762f737461626c652e737667)](https://packagist.org/packages/tomzx/html-parser)[![Latest Unstable Version](https://camo.githubusercontent.com/f7fe9d16a0b1e48f08e0c809508d43ab3902122b17e31c85dad68787fe967eea/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7a782f68746d6c2d7061727365722f762f756e737461626c652e737667)](https://packagist.org/packages/tomzx/html-parser)[![Build Status](https://camo.githubusercontent.com/4452b50f327600a8b80090c949b5727bd56e6f1ab329f50c67cde98c69dad319/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f6d7a782f68746d6c2d7061727365722e737667)](https://travis-ci.org/tomzx/html-parser)[![Code Quality](https://camo.githubusercontent.com/f1102da8321f670f8b34c086661cc286b7128d648362bfb84478186296864b40/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f6d7a782f68746d6c2d7061727365722e737667)](https://scrutinizer-ci.com/g/tomzx/html-parser/code-structure)[![Code Coverage](https://camo.githubusercontent.com/d84e1e981e72703243a66f9aacfd4a89253634edd1d2efe04802e267a37b7f6e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f746f6d7a782f68746d6c2d7061727365722e737667)](https://scrutinizer-ci.com/g/tomzx/html-parser)[![Total Downloads](https://camo.githubusercontent.com/bd872051ac0c9ff1524b3a923a1bc783c52e385bf5e6a7a9d1034538e37c739b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f6d7a782f68746d6c2d7061727365722e737667)](https://packagist.org/packages/tomzx/html-parser)

An HTML parser written in PHP. Based on [nikic's PHP Parser](https://github.com/nikic/PHP-Parser).

Getting started
---------------

[](#getting-started)

`HTML parser` goal is to simplify the traversal/modification of an HTML tree using the visitor pattern.

First, you'll want to parse your HTML using the `Parser` in order to generate a data structure appropriate for the `NodeTraverser`. Once that is done, you specify one or many visitors that implement the operation you want to apply on the HTML elements. Then, you traverse the HTML tree structure, which will call the visitors on every element entry/exit. Finally, you may print back the final output as a string.

```
