Download the PHP package kuria/simple-html-parser without Composer

On this page you can find all versions of the php package kuria/simple-html-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-html-parser

Simple HTML parser ##################

Minimalistic HTML parser.

Features

Requirements

Usage

Creating the parser

$parser = new SimpleHtmlParser($html);

Iterating elements

The parser implements Iterator so it can be traversed using the standard iterator methods.

if ($parser->valid()) { print_r($parser->current()); }

Element array structure

Each element is an array with the following keys. Some keys are available only for specific element types.

KeyTypesDescription
type start end name attrs symbolany any any SimpleHtmlParser::OPENING_TAG, SimpleHtmlParser::CLOSING_TAG SimpleHtmlParser::OPENING_TAG SimpleHtmlParser::OTHERThe type of the element, see Tag name and attribute normalization !, ? or /

Element types

Tag name and attribute normalization

Tag and attribute names that contain only ASCII characters are lowercased.

Managing parser state

The state methods can be used to temporarily store and/or revert state of the parser.

getHtml() - get HTML content

The getHtml() method may be used to get the entire HTML content or HTML of a single element.

getSliceBetween() - get content between 2 elements

The getSliceBetween() method returns a part of the HTML content that is between 2 elements (usually opening and closing tag).

getLength() - get length of the HTML

The getLength() returns total length of the HTML content.

getEncoding() - determine encoding of the HTML document

The getEncoding() method attempts to determine encoding of the HTML document.

If the encoding cannot be determined or is not supported, the fallback encoding will be used instead.

This method does not alter the parser's state.

getEncodingTag() - find the encoding-specifying meta tag

The getEncodingTag() method attempts to find the <meta charset="..."> or <meta http-equiv="Content-Type" content="..."> tag in the first 1024 bytes of the HTML document.

Returns NULL if the tag was not found.

This method does not alter the parser's state.

usesFallbackEncoding() - see if the fallback encoding is being used

The usesFallbackEncoding() indicates whether the fallback encoding is being used. This is the case when the encoding is not specified or is not supported.

This method does not alter the parser's state.

setFallbackEncoding() - set fallback encoding

The setFallbackEncoding() method specifies an encoding to be used in case the document has no encoding specified or specifies an unsupported encoding.

The fallback encoding must be supported by htmlspecialchars().

getDoctypeElement() - find the doctype element

The getDoctypeElement() method attempts to find the doctype in the first 1024 bytes of the HTML document.

Returns NULL if no doctype was found.

escape() - escape a string

The escape() method escapes a string using htmlspecialchars() using the HTML document's encoding.

find() - match a specific element

The find() method attempts to find a specific element starting from the current position, optionally stopping after a given number of bytes.

Returns NULL if no element was matched.

getOffset() - get current offset

The getOffset() method returns the current parser offset in bytes.

Example: Reading document's title

$parser = new SimpleHtmlParser($html);

$titleOpen = $parser->find(SimpleHtmlParser::OPENING_TAG, 'title');

if ($titleOpen) { $titleClose = $parser->find(SimpleHtmlParser::CLOSING_TAG, 'title');

if ($titleClose) { $title = $parser->getSliceBetween($titleOpen, $titleClose);

var_dump($title);

}

}

Output:

string(7) "Foo bar"

All versions of simple-html-parser with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kuria/simple-html-parser contains the following files

Loading the files please wait ....