XML_HTMLSax3
[ class tree: XML_HTMLSax3 ] [ index: XML_HTMLSax3 ] [ all elements ]

Source for file WordDoc.php

Documentation is available at WordDoc.php

  1. <?php
  2. /***
  3.  * $Id: WordDoc.php,v 1.4 2004/06/02 14:33:38 hfuecks Exp $
  4.  * Shows HTMLSax parsing Word generated HTML
  5.  */
  6. require_once('XML/HTMLSax3.php');
  7.  
  8. class MyHandler {
  9.     function escape($parser,$data{
  10.         echo('<pre>'.$data."\n\n\n</pre>");
  11.     }
  12. }
  13.  
  14. $h new MyHandler();
  15.  
  16. // Instantiate the parser
  17. $parser=new XML_HTMLSax3();
  18.  
  19. $parser->set_object($h);
  20. $parser->set_escape_handler('escape');
  21.  
  22. if isset($_GET['strip_escapes']) ) {
  23.     $parser->set_option('XML_OPTION_STRIP_ESCAPES');
  24. }
  25. ?>
  26. <h1>Parsing Word Documents</h1>
  27. <p>Shows HTMLSax parsing a simple Word generated HTML document and the impact of the option 'XML_OPTION_STRIP_ESCAPES' which can be set like;
  28. <pre>
  29. $parser->set_option('XML_OPTION_STRIP_ESCAPES');
  30. </pre>
  31. </p>
  32. <p>Word generates some strange XML / HTML escape sequences like &lt;![endif]&gt; - now (3.0.0+) handled by HTMLSax correctly.</p>
  33. <p>
  34.     <a href="<?php echo $_SERVER['PHP_SELF']?>">XML_OPTION_STRIP_ESCAPES = 0</a> :
  35.     <a href="<?php echo $_SERVER['PHP_SELF']?>?strip_escapes=1">XML_OPTION_STRIP_ESCAPES = 1</a>
  36. </p>
  37. <p>Starting to parse...</p>
  38. <?php
  39. // Parse the document
  40. $parser->parse(file_get_contents('worddoc.htm'));
  41. ?>
  42. <p>Parsing completed</p>

Documentation generated on Mon, 11 Mar 2019 15:11:50 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.