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

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;
}


相关文档:

ajax 发送xml文件,java接受xml文件并解析

红色字体为主要代码
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 ......

sql_map_config.xml(SQL Map环境文件)

<?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=" ......

fw_student_SqlMap.xml(SQL 和VO的映射文件)

<?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 ......

使用SQL操作XML简单示例

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 ......

Linq to XML customize distinct function

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)
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号