<?php
$arr=array();
$count=0;
$block="BOOK";
$key="";
$value="";
function startp($parser,$name,$att){
global $key;
$key=$name;
echo "open ".$key."<br>";
}
function endp($parser,$name){
global $count;
global $block;
echo "close ".$name."<br>";
if($name==$block){
$count=$count+1;
}
echo "count ".$count."<br>";
}
function dpage($parser,$data){
global $count;
global $value;
global $key;
global $arr;
if(strlen($data)>1){
echo "ทำ......".$key."ใส่ค่า".$data."<br>";
$value=$data;
$arr[$count]["$key"]=$value;
}
}
open MYBOOK
ทำ......MYBOOKใส่ค่า
open BOOK
ทำ......BOOKใส่ค่า
open NAME
ทำ......NAMEใส่ค่าC Pro
close NAME
count 0
ทำ......NAMEใส่ค่า
open NAME1
ทำ......NAME1ใส่ค่าC Pro1
close NAME1
count 0
ทำ......NAME1ใส่ค่า
open NAME2
ทำ......NAME2ใส่ค่าC Pro2
close NAME2
count 0
ทำ......NAME2ใส่ค่า
close BOOK
count 1
ทำ......NAME2ใส่ค่า
open BOOK
ทำ......BOOKใส่ค่า
open NAME
ทำ......NAMEใส่ค่าC Pro
close NAME
count 1
ทำ......NAMEใส่ค่า
open NAME1
ทำ......NAME1ใส่ค่าC Pro1
close NAME1
count 1
ทำ......NAME1ใส่ค่า
open NAME2
ทำ......NAME2ใส่ค่าC Pro2
close NAME2
count 1
ทำ......NAME2ใส่ค่า
close BOOK
count 2
close MYBOOK
count 2
Array ( [0] => Array ( [MYBOOK] => [BOOK] => [NAME] => [NAME1] => [NAME2] => ) [1] => Array ( [NAME2] => [BOOK] => [NAME] => [NAME1] => ) )