Login   Register  
PHP Classes
elePHPant
Icontem

File: xmlparser_loadfsm.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Dmitry A. Kirilin  >  FSM Parser  >  xmlparser_loadfsm.php  >  Download  
File: xmlparser_loadfsm.php
Role: Example script
Content type: text/plain
Description: XML parser with external FSM program
Class: FSM Parser
Generic parser using finite state machine
Author: By
Last change:
Date: 8 years ago
Size: 704 bytes
 

Contents

Class file image Download
<?
/*
 FSM Parser demo: the simple XML parser (using LoadFSMFile).
*/
include_once("fsmparserclass.inc.php");
$parser=new FSMParser();

//---------Functions to handle FSM events
function BeginTag($str){
 echo 
"+TAG:".$str;
}

function 
EndTag($str){
if(
strpos($str,'/')!==false)echo " CLOSED-";
echo 
"\n";
}

function 
ClosingTag($str){
 echo 
"-TAG:".trim($str,'<>/')."\n";
}

function 
GetSimpleAttr($str){
 echo 
" ".$str."=ON";
}

function 
GetValueAttr($str){
 
$v=explode("=",$str,2);
 echo 
" ".$v[0]."=".$v[1];
}

//---------Programming the FSM :)
$parser->LoadFSMFile("xmlparser_loadfsm.fsm");

//---------Run the parser
$parser->ParseFile("example.xml","CDATA");

?>