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

一些工具函数 Xml 序列化

  public sealed class XmlHelper
{
public static void Serialize<T>(T obj,string fileName)
{
TextWriter writer = new StreamWriter(fileName);
try
{
XmlSerializer ser = new XmlSerializer(typeof(T));
ser.Serialize(writer, obj);
}
catch (Exception)
{
throw;
}
finally
{
if (writer != null)
{
writer.Close();
}
}
}
public static T Deserialize<T>(string fileName) where T:class
{
TextReader reader = new StreamReader(fileName);
T newObj ;
try
{
XmlSerializer mySerializer = new XmlSerializer(typeof(T));
newObj= mySerializer.Deserialize(reader) as T;
}
catch (Exception)
{
throw;
}
finally
{
if (reader != null)
{
reader.Close();
}
}
return newObj;
}
public static T Deserialize<T>(FileInfo file) where T : class
{
string fileName = file.FullName;
return Deserialize<T>(fileName);
}
}


相关文档:

flex XML 作为数据源的实例(TESTED)

XML 作为数据源的实例(TESTED)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" preinitialize="preInit()" fontSize="12" height="500">
        <mx:Script>
     ......

10本经典XML及Web相关电子书


XML How to Program

Beginning Xml Databases

Beginning XSLT and XPath Transforming XML Documents and Data

ASP.NET 2.0 XML

XML 手册 4th Edition

XML Schema Complete Reference
......

java中使用dom4j写xml文件和简单教程

 
下载 dom4j-1.6.1.jar。
1: package org.zzp.common.xml.dom4j;
2:
3: import java.io.FileWriter;
4: import java.io.IOException;
5: import org.dom4j.Document;
6: import org.dom4j.DocumentHelper;
7: import org.dom4j.Element;
8: import org.dom4j.io.OutputFormat;
9: impor ......

java中使用dom4j读xml文件简单教程

需要dom4j.jar文件 ,自行下载。 test.xml 1: <?xml version="1.0" encoding="gbk"?>
2:
3: <students>
4: <person sex="男" age="21">
5: <id>1</id>
6: <name>章治鹏</name>
7: <homepage&g ......

JAVA 中用XML实现INI文件格式的解决方案

        这篇文章被转载的次数最多,其实代码简陋得我自己都看不下去。只不过发表这篇文章时很多人需要这个功能。
     
      这几天写个数据库查询分析器,要用到XML记录用户注册的数据库连接地址、端口等信息,最开始想用java ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号