一些工具函数 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);
}
}
相关文档:
得到一个需要处理的XMl
private string GetSaveItem()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<menuCollection/>");
foreach (TreeNode node in trvAccessRight.CheckedNodes)
{
if (node != trvAccess ......
DECLARE @x xml
SET @x='
<root>
<ShopAccount>
<ActivityType>IA - PM Standing WO (for LPI report)</ActivityType>
<ProjectNo>R</ProjectNo>
</ShopAccount>
<ShopAccount>
......
用java创建Xml的4大类:
Element:节点类
Attribute属性类
Document:指的就是文档类
XMLOutput:输出类
此类是用java建立一个xml文件
public class TestJdom {
//创建XML(模型)dom
public static void main(String[] args) {
  ......
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
......
Introduction to XML and XML With Java
If you are looking for sample programs to parse a XML file using DOM/SAX parser or looking for a program to generate a XML file please proceed directly to programs.
This small tutorial introduces you to the basic concepts of XML and using Xer ......