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

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

kuria/simple-html-parser
========================

Minimalistic HTML parser

v2.0.0(8y ago)332.8k↓30%2MITPHPPHP &gt;=7.1

Since Jan 13Pushed 3y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (2)

Simple HTML parser
==================

[](#simple-html-parser)

Minimalistic HTML parser.

[![https://travis-ci.com/kuria/simple-html-parser.svg?branch=master](https://camo.githubusercontent.com/6361260cdc54d620c2ec65e6923cc5d78cdd3f178db64e0ea3cd11898773eabb/68747470733a2f2f7472617669732d63692e636f6d2f6b757269612f73696d706c652d68746d6c2d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/kuria/simple-html-parser)Note

If you need advanced DOM manipulation, consider using `kuria/dom` instead.

Contents

- [Features](#features)
- [Requirements](#requirements)
- [Usage](#usage)
    - [Creating the parser](#creating-the-parser)
    - [Iterating elements](#iterating-elements)
    - [Element array structure](#element-array-structure)
        - [Element types](#element-types)
    - [Tag name and attribute normalization](#tag-name-and-attribute-normalization)
    - [Managing parser state](#managing-parser-state)
    - [`getHtml()` - get HTML content](#gethtml-get-html-content)
    - [`getSlice()` - get part of the HTML](#getslice-get-part-of-the-html)
    - [`getSliceBetween()` - get content between 2 elements](#getslicebetween-get-content-between-2-elements)
    - [`getLength()` - get length of the HTML](#getlength-get-length-of-the-html)
    - [`getEncoding()` - determine encoding of the HTML document](#getencoding-determine-encoding-of-the-html-document)
    - [`getEncodingTag()` - find the encoding-specifying meta tag](#getencodingtag-find-the-encoding-specifying-meta-tag)
    - [`usesFallbackEncoding()` - see if the fallback encoding is being used](#usesfallbackencoding-see-if-the-fallback-encoding-is-being-used)
    - [`setFallbackEncoding()` - set fallback encoding](#setfallbackencoding-set-fallback-encoding)
    - [`getDoctypeElement()` - find the doctype element](#getdoctypeelement-find-the-doctype-element)
    - [`escape()` - escape a string](#escape-escape-a-string)
    - [`find()` - match a specific element](#find-match-a-specific-element)
    - [`getOffset()` - get current offset](#getoffset-get-current-offset)
- [Example: Reading document's title](#example-reading-document-s-title)

[Features](#id1)
----------------

[](#features)

- parsing opening tags
- parsing closing tags
- parsing comments
- parsing DTDs
- extracting parts of HTML content
- determining encoding of HTML documents
- handling "raw text" tags (``, ``, ``, etc.)

[Requirements](#id2)
--------------------

[](#requirements)

- PHP 7.1+

[Usage](#id3)
-------------

[](#usage)

### [Creating the parser](#id4)

[](#creating-the-parser)

```
