Login   Register  
PHP Classes
elePHPant
Icontem

File: saxy_source.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of John Heinstein  >  SAXY XML parser  >  saxy_source.php  >  Download  
File: saxy_source.php
Role: Example script
Content type: text/plain
Description: Source code for the SAXY example
Class: SAXY XML parser
A Simple API for XML (SAX) parser
Author: By
Last change:
Date: 2004-01-22 21:17
Size: 902 bytes
 

Contents

Class file image Download
<?php
    
require_once("xml_saxy_parser.php");
    
    class 
SAXY_Test  {
    
        function 
SAXY_Test() {
            
$sp = new SAXY_Parser();
            
$sp->xml_set_element_handler(array(&$this"startElement"), array(&$this"endElement"));
            
$sp->xml_set_character_data_handler(array(&$this"charData"));
            
$sp->parse("<book><title><![CDATA[How to use SAXY]]></title><author>John Heinstein</author></book>");
        }
//SAXY_Test
        
        
function startElement($parser$name$attributes) {
            echo (
"<br /><b>Open tag:</b> " $name  "<br /><b>Attributes:</b> " print_r($attributestrue)  . "<br />");
        } 
//startElement
        
        
function endElement($parser$name) {
            echo (
"<br /><b>Close tag:</b> " $name  "<br />");
        } 
//endElement        
        
        
function charData($parser$text) {
            echo (
"<br /><b>Text node:</b> " $text  "<br />");
        } 
//charData
        
    
//SAXY_Test
    
    
$st = new SAXY_Test();
?>