Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

xmlµÄÐòÁл¯ºÍ·´ÐòÁл¯

XMLÐòÁл¯Óë·´ÐòÁл¯ ÕûÀíÎĵµ
XMLÐòÁл¯Óë·´ÐòÁл¯
    // OBJECT -> XML
    public static void SaveXml(string filePath, object obj) { SaveXml(filePath, obj, obj.GetType()); }
    public static void SaveXml(string filePath, object obj, System.Type type)
    {
        using (System.IO.StreamWriter writer = new System.IO.StreamWriter(filePath))
        {
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type);
            xs.Serialize(writer, obj);
            writer.Close();
        }
    }
    // XML -> OBJECT
    public static object LoadXml(string filePath, System.Type type)
    {
        if (!System.IO.File.Exists(filePath))
            return null;
        using (System.IO.StreamReader reader = new System.IO.StreamReader(filePath))
        {
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type);
            object obj = xs.Deserialize(reader);
            reader.Close();
            return obj;
        }
    }
Ïà¹ØµÄ³£ÓÃAttribute£¨ÃüÃû¿Õ¼äSystem.Xml.Serialization £©
    [XmlRootAttribute("PurchaseOrder", Namespace=


Ïà¹ØÎĵµ£º

XMLÈ¡½ÚµãÃû³ÆÓë½ÚµãֵʵÀý

declare @x xml
set @x='
<ROOT>
  <SM>
  <SMID>88</SMID>
  <SMCD>A5</SMCD>
  <SMNM>ÁõÑó</SMNM>
  <NDS>
  <ND>
  <SF>3</SF>
  <NDID>88</NDID>
  <NDCD>A5< ......

ʹÓà aspx Ò³Ãæ·µ»Ø xml ¸ñʽµÄֵʱ£¬ÐèҪעÒâд·¨

½â¾öÁË£¬ÊÇ1¥˵µÄ·½·¨£¬²»ÄÜд³É
context.Response.ContentType = "xml";
±ØÐëÒªÊÇ
context.Response.ContentType = "text/xml";
¾ÍOKÁË¡«
ʵÀý£º
  Response.ContentType = "text/xml";
            Page.Response.Write("<?xml version=\"1.0\" ......

XML Óï·¨¹æÔò


ת×Ô£ºhttp://www.w3school.com.cn/xml/xml_syntax.asp
XML µÄÓï·¨¹æÔòºÜ¼òµ¥£¬ÇÒºÜÓÐÂß¼­¡£ÕâЩ¹æÔòºÜÈÝÒ×ѧϰ£¬Ò²ºÜÈÝÒ×ʹÓá£
ËùÓÐ XML ÔªËØ¶¼ÐëÓйرձêÇ©
ÔÚ HTML£¬¾­³£»á¿´µ½Ã»ÓйرձêÇ©µÄÔªËØ£º
<p>This is a paragraph
<p>This is another paragraph
ÔÚ XML ÖУ¬Ê¡ÂԹرձêÇ©ÊÇ·Ç·¨µÄ¡£ËùÓÐÔª ......

ÊÖ´òÔ­xml±Ê¼ÇÊÖ³­±¾

1. <?xml version="1.0" encoding="GB2312" standalone="yes" ?>
       1.1 ÕâÊÇxmlµÄÎĵµÉùÃ÷£¬Ò»°ãλÓÚxmlÎļþµÄÊ×ÐС£
       1.2 Êéд¹æ·¶£º<?xmlΪһÌå Ö®¼ä²»ÄÜÓпոñ¡£
       1.3 encodingÊôÐÔ£¬Èç¹ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ