PHP Classes

File: examples/htmlparser.php

Recommend this page to a friend!
  Classes of Raskin Veniamin   VS PHP Word HTML   examples/htmlparser.php   Download  
File: examples/htmlparser.php
Role: Example script
Content type: text/plain
Description: Example script
Class: VS PHP Word HTML
Create DOCX Word document dynamically from HTML
Author: By
Last change:
Date: 9 years ago
Size: 550 bytes
 

Contents

Class file image Download
<?php
/**
* This example demonstrates the parsing HTML string and convert it into the document.
*/
require_once '../vsword/VsWord.php';
VsWord::autoLoad();

$doc = new VsWord();
$parser = new HtmlParser($doc);
$parser->parse('<h1>Hello world!</h1>');
$parser->parse('<h3>Hello world!</h3>');
$parser->parse('<p>Hello world!</p>');
$parser->parse('<h2>Header table</h2><table><tr><td>Coll 1</td><td>Coll 2</td></tr></table>');
$parser->parse($html);

echo
'<pre>'.($doc->getDocument()->getBody()->look()).'</pre>';

$doc->saveAs('htmlparser.docx');