Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oscarotero/html-parser
Simple utility to parse html strings to DOMDocument
https://github.com/oscarotero/html-parser
html parser
Last synced: 9 days ago
JSON representation
Simple utility to parse html strings to DOMDocument
- Host: GitHub
- URL: https://github.com/oscarotero/html-parser
- Owner: oscarotero
- License: mit
- Created: 2019-04-21T17:20:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-29T20:29:44.000Z (12 months ago)
- Last Synced: 2024-10-12T00:43:16.155Z (about 1 month ago)
- Topics: html, parser
- Language: HTML
- Size: 166 KB
- Stars: 15
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# HTML parser
Simple utility to parse html strings to DOMDocument.
```sh
composer require oscarotero/html-parser
```## Usage
```php
use HtmlParser\Parser;$html = 'Hello world';
//Convert a string to a DOMDocument
$document = Parser::parse($html);//Convert a string to a DOMDocumentFragment
$fragment = Parser::parseFragment('Hello world
');//Convert a DOMDocument or DOMDocumentFragment to a string
echo Parser::stringify($document);
echo Parser::stringify($fragment);
```