C#ÐòÁл¯Óë·´ÐòÁл¯Xml£¬ÀûÓ÷¶ÐÍ×öͨÓû¯´¦Àí
public class yzzSerialize
{
private yzzSerialize()
{ }
private static yzzCache cache = new yzzCache();
public static T GetfromXml<T>(string xmlpath, T t)
{
using (FileStream fs = new FileStream(xmlpath, FileMode.Open, FileAccess.Read))
{
Type type = typeof(T);
XmlSerializer xs = cache[type.FullName] as XmlSerializer;
if (xs == null)
{
xs = new XmlSerializer(type);
cache[type.FullName] = xs;
}
t = (T)xs.Deserialize(fs);
fs.Close();
return t;
}
}
public static void SetToXml<T>(string xmlpath, T t)
{
if (t == null)
return;
using (FileStream fs = new FileStream(xmlpath, FileMode.Create, FileAccess.Write))
{
Type type = typeof(T);
XmlSerializer xs = cache[type.FullName] as XmlSerializer;
if (xs == null)
{
xs = new XmlSerializer(type);
cache[type.FullName] = xs;
}
xs.Serialize(fs, t);
t = default(T);
fs.Close();
}
}
}
Ïà¹ØÎĵµ£º
C#
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Config/User_yhlx_Jb.xml"));
DataView dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "State=0";
this.DropDownList1.DataSource = dv;
this.DropDownList1.DataTextField = "text";
this ......
±àÒ룺C³ÌÐòÖ±½Ó±àÒë³É±ê×¼µÄ¶þ½øÖÆ¿ÉÖ´ÐеĴúÂ룬µ«C#µÄÔ´³ÌÐò²¢²»ÊDZ»±àÒë³É¶þ½øÖÆ¿ÉÖ´ÐеÄÐÎʽ£¬¶øÊÇÒ»ÖÖÖмäÓïÑÔ£¨MSIL£©£¬ÀàËÆJAVAÖеÄ×Ö½ÚÂë
½á¹¹Ì壺C#µÄ½á¹¹ÌåÓëC++µÄ½á¹¹ÌåÏàËÆ¡£µ«ÊÇC#µÄ½á¹¹ÌåÓëÀàÊDz»Í¬µÄ£¬¶øÇÒ²»Ö§³Ö¼Ì³Ð¡£
Ô¤±àÒ룺C#ÖдæÔÚÔ¤±àÒëµÄÖ¸ÁîÖ§³ÖÌõ¼þ±àÒ룬¾¯¸æ£¬´íÎ󱨸æºÍ±àÒëÐпØÖÆ¡£ÆäÖ¸Áî ......
/**
* ftpÉÏ´«ÎļþJavaBean
* @author Administrator
*
*/
public class FtpBean {
//ftp·þÎñµØÖ·
private String ftpUrl="";
//ftp̞
private String userName="";
//ftpÃÜÂë
private String passWord="";
public String getF ......
2£©ÈçºÎ´´½¨Ò»¸öxmlÎĵµ
ÓÉÓÚxmlʵÖÊÒ²Ö»ÊÇÒ»¸öÎı¾Îļþ£¬ËùÒÔ×î¼òµ¥Äã¿ÉÒÔÖ±½ÓʹÓÃSystem.IOϵÄÀàÉú³ÉÒ»¸öÎļþ£¬²¢´æ´¢³ÉxmlÎļþ£¬µ±È»£¬ÄãÐèÒªÊÖ¶¯±£Ö¤¸ÃÎļþÐÎʽÁ¼ºÃ£¬±ÈÈç±ØÐëÓиùÔªËØ¡¢±ØÐëÓйرձêÇ©¡¢±ØÐëÕýȷǶÌ׵ȵȡ£
Èç¹ûÄãÀÁµÃ×Ô¼ºÈ¥ÏëÎļþµÄÐÎʽ£¬¿ÉÒÔʹÓÃSystem.XmlϵÄÀà¡£
Code
Xml ......
3£©¶ÁÈ¡¡¢²éÕÒ
µ±ÄãÊÖÍ·ÓÐÒ»¸öxmlÎļþºó£¬¿ÉÒÔʹÓÃXmlDocument.Load()·½·¨½«Æä¼ÓÔؽøÀ´ÒԱ㴦Àí£¬ËùÒÔ“¶ÁÈ¡”ûÓÐʲô¿É˵µÄ¡£¶ø“²éÕÒ”²Ù×÷ÍùÍùÉæ¼°XPath£¬ÕâÀïÖ»ÊÇÎÒÈÏΪµÄ±È½Ï³£Óõ½µÄ²éÕÒ²Ù×÷£¬XPathÕâÍæÒâʵÔÚÊǺÜÇ¿´óºÜ±©Á¦¡£
»ØÍ·¿´Ê¾ÀýÎĵµxmlsample.xml£¬ÎÒÃÇ¿ÉÄÜÓöµ½ÕâÑùµÄÐèÇó£ ......