易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : xml

c# 支持XML序列化的泛型 Dictionary

/// <summary>
/// 支持XML序列化的泛型 Dictionary
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
[XmlRoot("SerializableDictionary")]
public class SerializableDictionary<TKey, TValue>
: Dictionary<TKey, TValue>, IXmlSerializable
{
#region 构造函数
public SerializableDictionary()
: base()
{
}
public SerializableDictionary(IDictionary<TKey, TValue> dictionary)
: base(dictionary)
{
}
public SerializableDictionary(IEqualityComparer<TKey> comparer)
: base(comparer)
{
}
public SerializableDictionary(int capacity)
: base(capacity)
{
}
public SerializableDictionary(int capacity, IEqualityComparer<TKey> comparer)
: base(capacity, comparer)
{
......

c# 支持XML序列化的泛型 Dictionary

/// <summary>
/// 支持XML序列化的泛型 Dictionary
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
[XmlRoot("SerializableDictionary")]
public class SerializableDictionary<TKey, TValue>
: Dictionary<TKey, TValue>, IXmlSerializable
{
#region 构造函数
public SerializableDictionary()
: base()
{
}
public SerializableDictionary(IDictionary<TKey, TValue> dictionary)
: base(dictionary)
{
}
public SerializableDictionary(IEqualityComparer<TKey> comparer)
: base(comparer)
{
}
public SerializableDictionary(int capacity)
: base(capacity)
{
}
public SerializableDictionary(int capacity, IEqualityComparer<TKey> comparer)
: base(capacity, comparer)
{
......

JPetStore 5.0(iBATIS for java)中Item.xml的bug

Caused by: java.sql.SQLException: ORA-00918: column ambiguously defined
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml. 
--- The error occurred while applying a parameter map. 
--- Check the getItem-InlineParameterMap. 
--- Check the statement (query failed). 
--- Cause: java.sql.SQLException: ORA-00918: column ambiguously defined
change  com\ibatis\jpetstore\persistence\sqlmapdao\sql\Item.xml to
红色为修改后的: 
<select id="getItem" resultClass="item" parameterClass="string" cacheModel="quantityCache">
      select
      I.ITEMID,
      I.LISTPRICE,
      I.UNITCOST,
      I.SUPPLIER AS supplierId,
      I.PRODUCTID AS "product.productId",
      ......

JPetStore 5.0(iBATIS for java)中Item.xml的bug

Caused by: java.sql.SQLException: ORA-00918: column ambiguously defined
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml. 
--- The error occurred while applying a parameter map. 
--- Check the getItem-InlineParameterMap. 
--- Check the statement (query failed). 
--- Cause: java.sql.SQLException: ORA-00918: column ambiguously defined
change  com\ibatis\jpetstore\persistence\sqlmapdao\sql\Item.xml to
红色为修改后的: 
<select id="getItem" resultClass="item" parameterClass="string" cacheModel="quantityCache">
      select
      I.ITEMID,
      I.LISTPRICE,
      I.UNITCOST,
      I.SUPPLIER AS supplierId,
      I.PRODUCTID AS "product.productId",
      ......

spring中读取xml配置文件、获取bean的几种方式

获取Spring框架管理的类实例的方法有多种,如下:
方法一:在初始化时保存ApplicationContext对象
代码:
ApplicationContext ac = new FileSystemXmlApplicationContext("applicationContext.xml");
ac.getBean("beanId");
说明:
这种方式适用于采用Spring框架的独立应用程序,需要程序通过配置文件手工初始化Spring的情况。
方法二:通过Spring提供的工具类获取ApplicationContext对象
代码:
import org.springframework.web.context.support.WebApplicationContextUtils;
ApplicationContext ac1 = WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext sc)
ApplicationContext ac2 = WebApplicationContextUtils.getWebApplicationContext(ServletContext sc)
ac1.getBean("beanId");
ac2.getBean("beanId");
说明:
这种方式适合于采用Spring框架的B/S系统,通过ServletContext对象获取ApplicationContext对象,然后在通过它获取需要的类实例。
上面两个工具方式的区别是,前者在获取失败时抛出异常,后者返回null。
方法三:继承自抽象类ApplicationObjectSupport
说明:
抽象类ApplicationObjectSuppo ......

动态创建XML文档


var createXML = function (str) {
if (typeof DOMParser !== "undefined") {
return (new DOMParser()).parsefromString(str, "application/xml");
}else if (typeof ActiveXObject != "undefined") {
if (typeof arguments.callee.activeXString !== "string"){//在createXML上设置一个静态成员
var versions = ["MSXML2.DOMDocument.6.0",
"MSXML2.DOMDocument.5.0",
"MSXML2.DOMDocument.4.0",
"MSXML2.DOMDocument.3.0",
"MSXML2.DOMDocument",
"Microsoft.XMLDOM"];
for (var i=0,len=versions.length; i < len; i++){
try {
var xml = new ActiveXObject(versions[i]);
arguments.callee.activeXString = versions[i];
xml = null;
} catch (e){}
}
}
xml = new ActiveXObject(arguments.callee.activeXString);
xml.async= ......

将数组转化为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;
        }
   ......

xml procedure

DECLARE @XMLdoc XML
SET @XMLdoc =
'<Book name="SQL Server 2000 Fast Answers">
<Chapters>
<Chapter id="1" name="Installation, Upgrades">
 <CreateDate>2009-12-30</CreateDate>
</Chapter>
<Chapter id="2" name="Configuring SQL Server"/>
<Chapter id="3" name="Creating and Configuring Databases">
 <CreateDate>2009-12-30</CreateDate>
</Chapter>
<Chapter id="4" name="SQL Server Agent and SQL Logs"/>
</Chapters>
</Book>'
DECLARE @docpointer int
EXEC sp_XML_preparedocument @docpointer OUTPUT, @XMLdoc
SELECT *
from OPENXML (@docpointer, '/Book/Chapters/Chapter',1)
WITH (Chapter int '@id',
ChapterNM varchar(50) '@name',
CreateDate VARCHAR(50) './CreateDate/text()')
GO
结果如下:
Chapter    ChapterNM                             ......
总记录数:815; 总页数:136; 每页6 条; 首页 上一页 [112] [113] [114] [115] 116 [117] [118] [119] [120] [121]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号