DataSet XMl DateTable 互转
/// <summary>
/// DataTable-------------------->XML --String
/// </summary>
public static String ToXmlString(DataTable dt)
{
StringWriter tr = new StringWriter();
try
{
dt.WriteXml(tr);
return tr.ToString();
}
catch
{
throw;
}
finally
{
tr.Dispose();
}
}
/// <summary>
/// DataSet----------------->XML---String
/// </summary>
public static String ToXmlString(DataSet ds)
{
StringWriter tr = new StringWriter();
try
{
ds.WriteXml(tr, XmlWriteMode.IgnoreSchema);
return tr.ToString();
}
catch
{
throw;
}
finally
{
tr.Dispose();
}
}
/// <summary>
/// xml转换为数据集
/// </summary>
public static DataSet XmlToDataSet(string xml)
{
try
{
StringReader sr = new StringReader(xml);
DataSet ds = new DataSet();
ds.ReadXml(sr);
return ds;
}
catch
{
throw;
}
}
/// <summary>
/// Xml转换为数据表
/// </summary>
public static DataTable ToDataTable(string xmlData, int TableIndex)
{
try
{
return XmlToDataSet(xmlData).Tables[TableIndex];
}
catch
{
throw;
}
}
相关文档:
红色字体为主要代码
jsp页面中
<script language="javascript">
function updateDB(operate){
var objDom=new ActiveXObject("msxml.DomDocument");
var objRoot=objDom.createElement("All");
objDom.appendChild(objRoot);
var k=document.ge ......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<!-- 配置和优化SQL Map解析实例的设定 -->
<settings cacheModelsEnabled=" ......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="fw_student">
<resultMap class="com.sias.Student" id="student">
<result column="name" property="na ......
declare @xml xml
set @xml = '<root/>'
select @xml
declare @value varchar(10)
set @value = 'val1'
set @xml.modify('insert <item value="{sql:variable("@value")}" /> into (/root)[1]')
select @xml
set @value = 'val2'
set @xml.modify('replace value of (/root/item/@value)[1] with "val2 ......
Definition comparer class,
class ItemComparer : IEqualityComparer<XElement>
{
public bool Equals(XElement x, XElement y)
{
return x.Attribute("Name").Value == x.Attribute("Name").Value;
}
public int GetHashCode(XElement obj)
......