Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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);
}
}


Ïà¹ØÎĵµ£º

java´´½¨Xml±Ê¼Ç


ÓÃjava´´½¨XmlµÄ4´óÀࣺ
 
Element£º½ÚµãÀà
AttributeÊôÐÔÀà
Document£ºÖ¸µÄ¾ÍÊÇÎĵµÀà
XMLOutput£ºÊä³öÀà
´ËÀàÊÇÓÃjava½¨Á¢Ò»¸öxmlÎļþ
 
public class TestJdom {
    //´´½¨XML£¨Ä£ÐÍ£©dom
    public static void main(String[] args) {
     ......

XML¸ñʽת»¯¹¤¾ßÀà

»ùÓÚdom4jµÄXML¸ñʽת»¯Àà
package com.lixi.util;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import org.dom4j.Document;
import org.do ......

XMLµÄʹÓÃ


дXML£º
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //ȨÏÞÅжÏ
        XmlTextWriter xmlw = new XmlTextWriter(Server.MapPath("~\\") + "FriendLink.xml", Encoding.Ge ......

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

spring ÖмÓÔØxmlÅäÖÃÎļþµÄ·½·¨

 
Ò»£ºSpringÖеļ¸ÖÖÈÝÆ÷¶¼Ö§³ÖʹÓÃxml×°Åäbean£¬°üÀ¨£º
    XmlBeanFactory £¬
    ClassPathXmlApplicationContext £¬
    FileSystemXmlApplicationContext £¬
    XmlWebApplicationContext
¼ÓÔØÕâЩÈÝÆ÷µÄÅäÖÃÎļþµÄxmlÓÐһϼ¸ÖÖ³£¼ûµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ