XMLÐòÁл¯ - .NET¼¼Êõ / C#
ÎÒ²»ÖªµÀÓÐûÓа취¿ÉÒÔ¸øÈÎÒâÒ»¸öÀà½øÐÐÐòÁл¯ºÍ·´ÐòÁл¯²Ù×÷¡£
C# code:
public static void Serial<T>(T[] items, string path)
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T[]));
TextWriter writer = new StreamWriter(path);
try
{
xmlSerializer.Serialize(writer, items);
}
finally
{
writer.Close();
}
}
public static T[] Deserial<T>(string path)
{
if (!File.Exists(path)) return new T[0];
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T[]));
FileStream fs = new FileStream(path, FileMode.Open);
T[] items;
try
{
items = (T[])xmlSerializer.Deserialize(fs);
}
finally
{
fs.Close();
}
return items;
}
Õâ¸öÊDZê×¼µÄxmlÐòÁл¯·´ÐòÁл¯µÄ·½·¨¡£Ò²ÐУ¬¾ÍÊDz»ÄÜÍêÈ«µÄ·ûºÏÎÒÒªÇó¡£
±ÈÈçÎÒµÄÀà
C# code:
public class A
{
public string P1;
}
ÎÒÈçºÎ×ö¶¼¿ÉÒÔ£¬µ«Èç¹ûÎÒÐòÁл¯Éú³ÉÁË"test.xml"Îļþ¡£
ÎÒÓÖÀ©Õ¹ÁËÀà±äΪ£º
C# code:
public class A
{
public string P1;
pulbic string P2;
}
ÎÒÓ÷´ÐòÁл¯µÃµ½µÄA[]¾Í»á¶¼ÊÇ¿ÕµÄÁË
Ïà¹ØÎÊ´ð£º
txt ºÍXML ¸ñʽÏàÓ¦
²»½èÖúDataSet
µ¼Èë¶ÁÈ¡TXTÎļþ
È»ºóÖ±½ÓдÈëXML(ͬһÎļþ,²»Í¬Êý¾Ý,µÝÔöÔÊý¾ÝûÓб»¸²¸ÇÇé¿öÏÂÔö¼ÓÊý¾Ý.)
½Ì¸öÒªµã»ò×îºÃÊÇÓиö´úÂëÌáʾµÄ
¹ý·ºÃºº °ï¸öæÈö^^
²»»á£¬°ïÂ¥Ö÷ ......
´ÓÊý¾Ý¿âÖвéѯһÕűíµÄÊý¾Ý
select ²¿ÃÅ,ÐÕÃû from tb
ÈçºÎ²ÅÄÜÉú³ÉÏÂÃæµÄxml¸ñʽ
XML code:
<folder state="unchecked" label="È«²¿">
¡¡¡¡ <folder state="unchecked&qu ......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎĶ¼¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
¹¦ÄÜ˵Ã÷:Java servlet °ÑXMLÊý¾ÝѹËõºó·¢Ë͵½PBÓû§¶Ë,PBÊÕµ½Êý¾Ýºó½âѹ³öÀ´.
´«ÊäÒª¾¹ýBase64±àÂë.
ÎÊÌâÊÇ:ÄÜÊÕµ½Êý¾Ýµ«Êǽâѹ²»³öÀ´.ÏëÇë½Ì´ó¼Ò»òÕßÓÐʲôºÃµÄ°ì·¨?
PB¿ÉÒÔÓÃ"zlibwapi.DLL" ½âѹ
......
´ó¼ÒºÃ£¬ÎÒÊÇÐÂÊÖ£¬¸Õ¿ªÊ¼½Ó´¥C/S½á¹¹µÄ³ÌÐò£¬ÏëҪʵÏÖÒ»¸ö·ÖÒ³¹¦ÄÜ£¬´ó¼ÒÓÐûÓкõãµÄ·ÖÒ³¿Ø¼þ»òÕß³ÌÐòÖ®ÀàµÄ£¬µ±È»Ô´³ÌÐò¸üºÃ£¬·ñÔò˵˵Á÷³ÌÒ²¿ÉÒÔ£¬Ð¡Ãü±°¡£¬ÔÚÏߵȡ£¡£¡£¡£
´ó¼Ò°ï°ï棬лÁË£¡
×Ô¼ºÐ´Ñ½£¡
......