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

xml与dataset(datatable)互转

引用类库:
 using System;
 using System.Data;
 using System.IO;
 using System.Xml;
using System.Text;
// 相应C#代码:
private string ConvertDataTableToXML(DataTable xmlDS)
{
MemoryStream stream = null;
XmlTextWriter writer = null;
try
{
stream = new MemoryStream();
writer = new XmlTextWriter(stream, Encoding.Default);
xmlDS.WriteXml(writer);
int count = (int)stream.Length;
byte[] arr = new byte[count];
stream.Seek(0, SeekOrigin.Begin);
stream.Read(arr, 0, count);
UTF8Encoding utf = new UTF8Encoding();
return utf.GetString(arr).Trim();
}
catch
{
return String.Empty;
}
finally
{
if (writer != null) writer.Close();
}
}
private DataSet ConvertXMLToDataSet(string xmlData)
{
StringReader stream = null;
XmlTextReader reader = null;
try
{
DataSet xmlDS = new DataSet();
stream = new StringReader(xmlData);
reader = new XmlTextReader(stream);
xmlDS.ReadXml(reader);
return xmlDS;
}
catch (Exception ex)
{
string strTest = ex.Message;
return null;
}
finally
{
if (reader != null)
reader.Close();
}


相关文档:

支持几乎所有浏览器的js载入xml文件

1.route.xml文件内容
<?xml version="1.0" encoding="GBK"?>
<root>
<route id="1111">
<id>111</id>
<name>四川</name>
<path>www.baidu.com/hehe.html</path>
</route>
</root>
2.test.html代码
<html>
<body>
<script> ......

C# Xml中映射为类数据结构(报文)

        [System.Runtime.Serialization.DataMemberAttribute()]
        public Information Archive {
            get {
         &n ......

VB.NET中操作xml文件(插入节点、修改、删除)

已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price>
</book>
< ......

Sql Server 对xml类型的操作

 declare @XML XML
SET @XML='<root>
 <OLDVALUE>
  <H_Action id="1130">030</H_Action>
  <D_Action>030</D_Action>
  <OrderCompany>00220</OrderCompany>
  <OrderNumber>10004035</OrderNumber> ......

jdom读取xml文件


import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
(1)使用JDOM首先要指定使用什么解析器。如:
          SAXBuilder builder=new SAXBuilder(false) ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号