易截截图软件、单文件、免安装、纯绿色、仅160KB

一个简单的xml类,可以解析和生成xml文件数据

<?php
include('xml.php');
$data = XML_unserialize($xml);
?>
$xml即是xml文件的内容,$data是解析出的数组;
<?php
include('xml.php');
$xml = XML_serialize($data);
?>
以上为使用实例,分别解析xml文档和生成xml格式的数据
xml.php源码
<?php
###################################################################################
#
# XML Library, by Keith Devens, version 1.2b
# http://keithdevens.com/software/phpxml
#
# This code is Open Source, released under terms similar to the Artistic License.
# Read the license at http://keithdevens.com/software/license
#
###################################################################################
###################################################################################
# XML_unserialize: takes raw XML as a parameter (a string)
# and returns an equivalent PHP data structure
###################################################################################
function & XML_unserialize(&$xml){
$xml_parser = &new XML();
$data = &$xml_parser->parse($xml);
$xml_parser->destruct();
return $data;
}
###################################################################################
# XML_serialize: serializes any PHP data structure into XML
# Takes one parameter: the data to serialize. Must be an array.
###################################################################################
function & XML_serialize(&$data, $level = 0, $prior_key = NULL){
if($level == 0){ ob_start(); echo '<?xml version="1.0" ?>',"\n"; }
while(list($key, $value) = each($data))
if(!strpos($key, ' attr')) #if it's not an attribute
#we don't treat attributes by themselves, so for an empty element
# that has attributes you still need to set the element to NULL
if(is_array($value) and array_key_exists(0, $value)){
XML_serialize($value, $level, $key);
}else{
$tag = $prior_key ? $prior_key : $key;
echo str_repeat("\t", $level),'


相关文档:

FOR XML语法导出XML的易错之处

原文地址:http://www.cnblogs.com/zhengyun_ustc/archive/2006/06/29/sqlxml_forxmlexplicit.html
[SQLXML]FOR XML语法导出XML的易错之处
Version
Date
Creator
Description
1.0.0.1
2006-6-29
郑昀@Ultrapower
草稿
 
继续阅读之前,我们假设您熟悉以下知识:
n      &nb ......

关于SQLServer2005的学习笔记——XML的处理


SQLServer2005
中对
XML
的处理功能显然增强了很多,提供了
query(),value(),exist(),modify(),nodes()
等函数。
关于
xml
,难以理解的不是
SQLServer
提供的函数,而是对
xml
本身的理解,看似很简单的文件格式,处理起来却是非常困难的。本文只是初探一下而已。
详见
SQLServer
联机帮助:
主题
说 ......

.net中XML文件作为数据源的操作类

不解释了,自己看代码吧.......................
using System;
using System.Text;
using System.Data;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Xml;
namespace Gogofly.CommonOperation
{
 /// <summary>
 /// ......

利用 DataSet or DataTable 读取 格式不规则的xml文件

       在最近的项目中,偶遇到一个可以说很小的问题,静下心来,有想把它记下来的冲动,随产生这不成文的几段文字。
       在我用ReadXml()和ReadSchema()读取XML文件时,总是出现异常,后来经过调试发现报XmlException异常并提示“缺少根元素&rd ......

HTML,XHTML和XML的区别

(1)XML
XML是The Extensible Markup Language(可扩展标识语言)的简写。目前推荐遵循的是W3C于2000年10月6日发布的XML1.0,参考(www.w3.org/TR/2000/REC-XML-20001006)。和HTML一样,XML同样来源于SGML,但XML是一种能定义其他语言的语。XML最初设计的目的是弥补HTML的不足,以强大的扩展性满足网络信息发布的需要,后 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号