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

Xml序列化和反序列化

经常见XML序列化的文章,对该序列化方式并不是太晓得,看了MSDN和一些资料后有了大致的了解,大道理讲不出来,上 代码先:
方式一 通过XmlSerialize直接序列化:
Class BeSerialized
{
//某字段
public int someFiled; 
//公共类的一个可序列化的属性
private bool serialme;
public bool SerialMe
{
     get { return serialme; }
     set { serialme = value; }
}
 
}
class process
{
public void Main()
{
SerialIt();
DeSerialIt();
}
SerialIt()
{
BeSerialized bs=new BeSerialized();
bs.someFiled=;
bs.SerialMe=;
XmlSerialize xs=new XmlSerialize(typeof(BeSerialized));
StreamWriter sw=
xs.Serialze(sw,bs);
}
DeSerialIt()
{
XmlSerialze xs=new XmlSerialize(typeof(BeSerialized));
StreamReader sr
BeSerialized bs=(BeSerialized)xs.DeSerialize(sr);
}
}
方式二 手动在要序列化的类设置属性类型
public class Student
{
    private int id;
    [xmlAttribute]
    public int ID   //序列化时作为Student节点的属性而不是默认的子节点
    {
        get { return id; }
        set { id = value; }
    }
    private string name;
   [XmlElement("sname")]
    public string Name  //节点名称为sname而不是默认的Name
    {
        get { return name; }
        set { name = value; }
    }
    private int age;
    [XmlIgnore]
    public int Age      //忽略该属性,不存入XML文件
    {
        get { return age; }
        set { age = value; }
    }
    internal int score = 88;
    public override string ToString()
    {


相关文档:

Retrieving an XML document using Ajax


Retrieving an XML document using Ajax
http://www.javascriptkit.com/dhtmltutors/ajaxgetpost3.shtml
When making a server request in Ajax, the data returned can be in either
plain text/html, or an XML document instead. The later is technically
just a text file as well, but with s ......

XML 查询、添加、修改、删除

Query:
XmlDocument doc = new XmlDocument();
  
doc.Load(Server.MapPath(".\\db\\dbGuest.xml"));
           
//User是XML根节点,Name字节点
      lbEmail.Text =
doc.SelectSingleNode("//User ......

DataSet与xml文件的互相转换


http://www.cnblogs.com/long2006sky/articles/1258731.html
DataSet转换为xml文件
//将DataSet转换为xml文件
        private static void ConvertDataSetToXMLFile(DataSet xmlDS, string xmlFile)
        {
    &n ......

js 读取xml文档

<html>
<head>
<title>XML Demo</title>
</head>
<body>
<script language="javascript">
function window.onload()
{
var domXML=new ActiveXObject("Microsoft.xmldom");
domXML.load("aTest.xml");
var myRoot=domXML.documentElement;
var myNodes2=myRoot.child ......

Flex调用远程XML数据

首先要有一个简易的服务器,建立一个站点,然后站点下存放 
1:crossdomain.xml 这个是跨与域策略文件,用于指定域通过Flash
Player访问本域的资源(如果服务器在本机就没有这个必要)但是远程的话就要(建议要)
文件内容:
<cross-domain-policy>
  <allow-access-from domain="*" /> ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号