<?php

class xml{
 var $parser;
 var $document;
 var $stack;
 var $data;
 var $last_opened_tag;
 var $isnormal;
 var $attrs=array();
 var $failed=false;
 function __construct($isnormal){
  $this->XMLparse($isnormal);
 }
 function XMLparse($isnormal){
  $this->isnormal=$isnormal;
  $this->parser=xml_parser_create('ISO-8859-1');
  xml_parser_set_option($this->parser,XML_OPTION_CASE_FOLDING,false);
  xml_set_object($this->parser,$this);
  xml_set_element_handler($this->parser,'open','close');
  xml_set_character_data_handler($this->parser,'data');
 }
 function destruct(){
  xml_parser_free($this->parser);
 }
 function parse(&$data){
  $this->document=array();
  $this->stack=array();
  return xml_parse($this->parser,$data,true)&&!$this->failed?$this->document:'';
 }
 function open(&$parser,$tag,$attributes){
  $this->data='';
  $this->failed=false;
  if(!$this->isnormal){
   if(isset($attributes['id'])&&!is_string($this->document[$attributes['id']])){
    $this->document=&$this->document[$attributes['id']];
   }else{
    $this->failed=true;
   }
  }else{
   if(!isset($this->document[$tag])||!is_string($this->document[$tag])){
    $this->document=&$this->document[$tag];
   }else{
    $this->failed=true;
   }
  }
  $this->stack[]=&$this->document;
  $this->last_opened_tag=$tag;
  $this->attrs=$attributes;
 }
 function data(&$parser,$data){
  if($this->last_opened_tag!=null){
   $this->data.=$data;
  }
 }
 function close(&$parser,$tag){
  if($this->last_opened_tag==$tag){
   $this->document=$this->data;
   $this->last_opened_tag=null;
  }
  array_pop($this->stack);
  if($this->stack){
   $this->document=&$this->stack[count($this->stack)-1];
  }
 }
}
?>

xml_class来自 phpcms的更多相关文章

  1. php Zend Opcache,xcache,eAccelerator缓存优化详解及对比

    XCACHE XCache 是一个开源的 opcode 缓存器/优化器, 这意味着他能够提高您服务器上的 PHP 性能. 他通过把编译 PHP 后的数据缓冲到共享内存从而避免重复的编译过程, 能够直接 ...

  2. 使用strace查看C语言级别的php源码

    XCACHE XCache 是一个开源的 opcode 缓存器/优化器, 这意味着他能够提高您服务器上的 PHP 性能. 他通过把编译 PHP 后的数据缓冲到共享内存从而避免重复的编译过程, 能够直接 ...

  3. phpcms V9 内容模型管理

    [1]理解模型 模型,系统知识的抽象表示.既然抽象了,那就得脑补一下.大家都是面向对象设计的专业人员,类就很抽象的,对比类的定义想象一下模型的概念. 举个例子,一般新闻类的信息,都具有标题.内容.作者 ...

  4. phpcms万能字段如何使用php方法

    来自:http://www.tantengvip.com/2013/12/phpcms-php-function/ phpcms后台内容模块->模型管理->添加字段功能很强大,你只需在ph ...

  5. 【转】phpcms授课学习

    来自:http://blog.csdn.net/yanhui_wei/article/category/1220735 <?php 思路: 一.目前在企业中使用比较多的cms内容管理有如下几种: ...

  6. phpcms后台部分修改

    1.后台登陆前提示信息取消及成功后提示信息取消.    (1)后台登陆前提示信息取消               phpcms\modules\admin\classes\admin.class.ph ...

  7. phpcms V9 内容模型管理(转)

    转自:http://www.cnblogs.com/Braveliu/p/5102627.html [1]理解模型 模型,系统知识的抽象表示.既然抽象了,那就得脑补一下.大家都是面向对象设计的专业人员 ...

  8. PHPCMS v9 模型概念及用法

    phpcms v9 模型概念 一.什么是模型? 模型是系统知识的抽象表示.我们不能仅仅通过语言来描述一个系统,也不能仅仅通过记忆来记录关于系统的知识.知识是通过某种媒介来表达的,这种媒介所表达的内容就 ...

  9. 搜查的PHPCMS,织梦DEDECMS 部分对比分析

    对于初学者来说,我想会有相对的了解和认识,自然也有助于今后前端面试的一些小细节!当下学的自然是phpcms phpcms优点: 1. 模块化安装,非常适合安装,拆卸非常方便的. 2. 灵活的标签语法, ...

随机推荐

  1. tomcat运行方式详解

    tomcat的运行模式有3种 一.bio(blocking I/O) 即阻塞式I/O操作,表示Tomcat使用的是传统的Java I/O操作(即java.io包及其子包).是基于JAVA的HTTP/1 ...

  2. sklearn 模型评估

    原文链接 http://d0evi1.com/sklearn/model_evaluation/ 预测值:pred 真实值:y_test #### 直接用平均值 ``` mean(pred == y_ ...

  3. matlab 高级

    绘图 条形图 x = [1:10]; y = [75, 58, 90, 87, 50, 85, 92, 75, 60, 95]; bar(x,y), xlabel('Student'),ylabel( ...

  4. JavaWeb部分视频\2-12JSP,EL和JSTL

    JavaWeb知识结构图 第3节 EL介绍和运算符 && 第4节 EL获取域中存储的数据 ## EL表达式 1. 概念:Expression Language 表达式语言 2. 作用: ...

  5. The mplot3d Toolkit

    简介 正如,pyplot模块被用来绘制二维图,matplotlib使用mplot3d模块绘制三维图形,在mplot3d模块中存在 mpl_toolkits.mplot3d.axes3dmpl_tool ...

  6. 国产手机早就异军突起,为何还是有很多人“迷恋”iPhone?

    近几年,国产手机不论是从外观上还是设计上,以及销量上都比前有了长足的进步,手机的品质和售后也在不断提升.这也让中国手机厂商不断的推出了拥有自己品牌特色的产品.特别是2018年不少国产手机品牌的旗舰级产 ...

  7. 计量经济与时间序列_关于Box-Jenkins的ARMA模型的经济学意义(重要思路)

    1 很多人已经了解到AR(1)这种最简单的时间序列模型,ARMA模型包括AR模型和MA模型两个部分,这里要详细介绍Box-Jenkins模型的观念(有些资料中把ARMA模型叫做Box-Jenkins模 ...

  8. dubbo的重试原则

    验证思路.使用超时来验证重试次数 XML 注解

  9. 吴裕雄--天生自然TensorFlow高层封装:使用TFLearn处理MNIST数据集实现LeNet-5模型

    # 1. 通过TFLearn的API定义卷机神经网络. import tflearn import tflearn.datasets.mnist as mnist from tflearn.layer ...

  10. TPO6-1 Powering the Industrial Revolution

    By 1800 more than a thousand steam engines were in use in the British Isles, and Britain retained a ...