home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / xamp / xampp-win32.exe / xampp / 001.phpt < prev    next >
Encoding:
Text File  |  2004-10-01  |  1.2 KB  |  50 lines

  1. --TEST--
  2. XML Parser: parse simple string
  3. --SKIPIF--
  4. <?php if (!extension_loaded("xml")) echo 'skip'; ?>
  5. --FILE--
  6. <?php
  7. //
  8. // Test for: XML/Parser.php
  9. // Parts tested: - parser creation
  10. //               - some handlers
  11. //               - parse simple string
  12. //
  13.  
  14. require_once "../Parser.php";
  15.  
  16. class __TestParser1 extends XML_Parser {
  17.     function __TestParser1() {
  18.         $this->XML_Parser();
  19.     }
  20.     function startHandler($xp, $element, $attribs) {
  21.         print "<$element";
  22.         reset($attribs);
  23.         while (list($key, $val) = each($attribs)) {
  24.             $enc = htmlentities($val);
  25.             print " $key=\"$enc\"";
  26.         }
  27.         print ">";
  28.     }
  29.     function endHandler($xp, $element) {
  30.         print "</$element>\n";
  31.     }
  32.     function cdataHandler($xp, $cdata) {
  33.         print "<![CDATA[$cdata]]>";
  34.     }
  35.     function defaultHandler($xp, $cdata) {
  36.  
  37.     }
  38. }
  39. error_reporting(1023);
  40. print "new __TestParser1 ";
  41. var_dump(get_class($o = new __TestParser1()));
  42. print "parseString ";
  43. var_dump($o->parseString("<?xml version='1.0' ?><root>foo</root>", 1));
  44.  
  45. ?>
  46. --EXPECT--
  47. new __TestParser1 string(13) "__testparser1"
  48. parseString <ROOT><![CDATA[foo]]></ROOT>
  49. bool(true)
  50.