File: example.php

Recommend this page to a friend!
  Classes of Dave Smith  >  HTML Parser  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: HTML Parser
Parse HTML using DOMDocument
Author: By
Last change: Small typo fix in comment
Date: 6 years ago
Size: 1,054 bytes


Class file image Download

//instantiate the class
$parser = new html_parser;

//use this method to load the markup as a file
//comment the line below if you are using the string method


//use this method to load the markup as a string
//uncomment both lines to load as a string

//$page = file_get_contents('example.html');

//uncomment the method you want to use to process the markup
//processDocument will parse the entire markup
//processTagName will parse the document for the specified tag name, set option to true to include descendents
//processElementID will parse and return the tag name of the element containing the specified id

$parseResult = $parser->processDocument();
//$parseResult = $parser->processTagName('p',false);
//$parseResult = $parser->processElementID('salesTable');

if( empty($parser->error) ){


For more information send a message to info at phpclasses dot org.