PHP Classes

File: examples/tree.php

Recommend this page to a friend!
  Classes of Raskin Veniamin   VS PHP Word HTML   examples/tree.php   Download  
File: examples/tree.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: 757 bytes
 

Contents

Class file image Download
<?php
/**
* Example translates a nested list of HTML in docx
*/

require_once '../vsword/VsWord.php';
VsWord::autoLoad();

$doc = new VsWord();
$parser = new HtmlParser($doc);

$html = '<ul>
        <li>Level Node 1</li>
        <li>Level Node 2</li>
        <li>Level Node 3
        <ul>
            <li>Level Node 2</li>
            <li>Level Node 2</li>
            <li>Level Node 2
            <ul>
                <li>Level Node 3</li>
                <li>Level Node 3</li>
                <li>Level Node 3
                <ul>
                    <li>Level Node 4</li>
                </ul></li>
            </ul>
            </li>
            <li>Level Node 2</li>
    </ul></li>
    <li>Level Node 1</li>
    <li>Level Node 1</li>
    <li>Level Node 1</li></ul>
'
;

$parser->parse($html);
echo
'<pre>'.($doc->getDocument()->getBody()->look()).'</pre>';
$doc->saveAs('tree.docx');