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

将数组转化为XML数据

/* Author: 杨宇  yangyu@sina.cn */
/*
用法示例:
$cls_xml = new cls_xml();
if ($array){
 $cls_xml->array2xml($array);
 echo $cls_xml->getXml(); 
}else{
 echo '';
}
*/
class cls_xml{
        var $xml;
        public function array2xml($array,$encoding='gb2312'){
                $this->xml = '<?xml version="1.0" encoding="'.$encoding.'"?><list>';
                $this->xml.= $this->_array2xml($array).'</list>';
        }
        public function getXml(){
                return $this->xml;
        }
        public function _array2xml($array){
                $xml = '';
    foreach($array as $key => $val){
                        is_numeric($key)  &&  $key = "item id=\"$key\"";
                        $xml. = "<$key>";
                        $xml. = is_array($val) ? $this->_array2xml($val) : $this->_cdata($val);
                        list($key,) = explode(' ',$key);
 


相关文档:

XML Schema 帮助文档4

XML Schema import 元素
定义和用法
import 元素用于向一个文档添加带有不同目标命名空间的多个 schema。
元素信息
出现次数
无限制
父元素
schema
内容
annotation
语法
<import
id=ID
namespace=anyURI
schemaLocation=anyURI
any attributes
>
(annotation?)
< ......

xml shema帮助文档5

XML Schema union 元素
定义和用法
union 元素定义多个 simpleType 定义的集合。
元素信息
出现次数
一次
父元素
simpleType
内容
annotation、simpleType
语法
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType ......

C#小Tip:Xml操作简明手册 1


1)Xml文档示例(xmlsample.xml):
 
Code
<?xml version="1.0" encoding="iso-8859-1" ?>
<music>
  <song title="Oh,girl">
    <artist>The Chi-lites</artist>
    <genre>Soul</genre>
  &nb ......

C#序列化与反序列化Xml,利用范型做通用化处理

public class yzzSerialize
{
private yzzSerialize()
{ }
private static yzzCache cache = new yzzCache();
public static T GetfromXml<T>(string xmlpath, T t)
{
using (FileStream fs = new FileStream(xmlpath, FileMode.Open, FileAcces ......

dom4j 解析 xml 例子

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
SAXReader reader = new SAXReader();
try {
          Document doc = reader.read("ParserSQL.xml");
   &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号