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

C#СTip£ºXml²Ù×÷¼òÃ÷ÊÖ²á 2


2£©ÈçºÎ´´½¨Ò»¸öxmlÎĵµ
ÓÉÓÚxmlʵÖÊÒ²Ö»ÊÇÒ»¸öÎı¾Îļþ£¬ËùÒÔ×î¼òµ¥Äã¿ÉÒÔÖ±½ÓʹÓÃSystem.IOϵÄÀàÉú³ÉÒ»¸öÎļþ£¬²¢´æ´¢³ÉxmlÎļþ£¬µ±È»£¬ÄãÐèÒªÊÖ¶¯±£Ö¤¸ÃÎļþÐÎʽÁ¼ºÃ£¬±ÈÈç±ØÐëÓиùÔªËØ¡¢±ØÐëÓйرձêÇ©¡¢±ØÐëÕýȷǶÌ׵ȵȡ£
 
Èç¹ûÄãÀÁµÃ×Ô¼ºÈ¥ÏëÎļþµÄÐÎʽ£¬¿ÉÒÔʹÓÃSystem.XmlϵÄÀà¡£
 
Code
XmlDocument xdoc = new XmlDocument();
XmlDeclaration xdcl = xdoc.CreateXmlDeclaration("1.0", "iso-8859-1", "");
xdoc.AppendChild(xdcl);
//XmlNode xnode = xdoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
//xdoc.AppendChild(xnode);
//Of course you can use CreateNode here(with the XmlNodeType.Element),
//so no more questions about 'what difference between this 2 methods?',
XmlElement root = xdoc.CreateElement("music");
xdoc.AppendChild(root);
XmlElement xelm = xdoc.CreateElement("song");
xelm.SetAttribute("title", "Oh,girl");
xelm.InnerText = "Oh,girl,i'd be in trouble if you left me now";
root.AppendChild(xelm);
try
{
     xdoc.Save("xmlsample-1.xml");
}
catch (Exception ex)
{
     Console.WriteLine(ex.Message);
}
½á¹û£º
Code
<?xml version="1.0" encoding="iso-8859-1"?>
<music>
  <song title="Oh,girl">Oh,girl,i'd be in trouble if you left me now</song>
</music>
 
ÓÉÓÚÏñXmlDeclaration¡¢XmlElementÕâЩÀ඼¼Ì³Ð×ÔXmlNode£¬¹ÊCreateNode()·½·¨ÊÇ×îͨÓõģ¬¿ÉÒÔͨ¹ýʹÓÃXmlNodeTypeÀ´Éú³É²»Í¬ÀàÐ͵Ľڵ㡣
ÁíÍ⣬ÍùÔªËØÖвåÈëÎı¾£¬Ê¹ÓõÄÊôÐÔÊÇ“InnerText”¡£
 
·½·¨¶þ£º
XmlDocument»¹ÓÐÒ»¸öLoadXml()·½·¨£¬Êµ¼ÊÉϸúÒ»ÐÐÒ»ÐÐдÈëÎı¾Ã»Çø±ð£¬¾ÍÊÇÔ¤ÏÈдºÃxml£¬²¢°ÑËü×÷Ϊ×Ö·û´®´«¸øLoadXml()·½·¨¡£
 
·½·¨Èý£º
Èç¹ûÄãÊÖÍ·ÓÐÒ»¸öDataTable£¬»¹¿ÉÒÔʹÓÃDataTable.WriteXml()·½·¨¡£
 
Code
DataTable dt = new DataTable("music");
dt.Columns.Add("title", typeof(string));
dt.Columns.Add("artist");
dt.Columns.Add("genre");
dt.Columns.Add("album");
//
dt.Rows.Add("Oh,girl", "The Chi-lites", "Soul", "A lonely man");
dt.Rows.Add("What if", "Babyface", "R&B", "Unkno


Ïà¹ØÎĵµ£º

SQLServer 2005 ÖеÄÀàÐÍ Óë C# ÖеÄÀàÐÍ ¶ÔÓ¦ ¹Øϵ

<Language from="SQL" To="C#">
   <Type from="bigint" To="long" />
   <Type from="binary" To="object" />
   <Type from="bit" To="bool" />
   <Type from="char" To="string" />
   <Type from="datetime" To="DateTime" ......

XML Schema°ïÖúÎĵµ2

XML Schema annotation ÔªËØ
¶¨ÒåºÍÓ÷¨
annotation ÔªËØÊÇÒ»¸ö¶¥²ãÔªËØ£¬¹æ¶¨ schema µÄ×¢ÊÍ¡£
×¢ÊÍ£º¿ÉÒÔ°üº¬ appinfo ÔªËØ£¨ÓÉÓ¦ÓóÌÐòʹÓõÄÐÅÏ¢£©ºÍ documentation ÔªËØ£¨ÓÉÓû§¶ÁÈ¡»òʹÓõÄ×¢ÊÍ»òÎı¾£©¡£
ÔªËØÐÅÏ¢
씀˵Ã÷
³öÏÖ´ÎÊý
ÔÚ¸¸ÔªËØÖÐÒ»´Î¡£ ......

c# XMLÐòÁл¯Óë·´ÐòÁл¯

Ô­ÏÈÒ»Ö±ÓÃBinaryFormatterÀ´ÐòÁл¯Í¦ºÃ£¬¿ÉÊÇ×î½ü·¢ÏÖÔÚWinCEÏÂÊÇûÓа취½øÐÐBinaryFormatter²Ù×÷£¬ºÜ²»Ë¬£¬Ö»ÄܸijÉÁËBinaryWriterºÍBinaryReaderÀ´¶Áд£¬Í»È»Ïëµ½Äܲ»ÄÜÓÃXMLÀ´ÐòÁл¯£¿ÓÚÊÇÔÚÍøÉϲéÁËЩ×ÊÁϱãдÁËЩʵ¼ùÐÔ´úÂ룬×öЩ¼Ç¼£¬±ÜÃâÒÔºóÍü¼Ç¡£
ÐòÁл¯¶ÔÏó
    public class People
  ......

³õѧXML£¨¶þ£© XML½âÎöÆ÷

XML½âÎöÆ÷µÄ×÷ÓãºÎªÓ¦ÓóÌÐò´ÓXMLÎļþÖнâÎö³öËùÐèÒªµÄÊý¾Ý¡£
ÏÂÃæͨ¹ýÒ»¸öÀý×Ó£¬À´Á˽⣬ÈçºÎÓÃXML½âÎöÆ÷£¬À´½âÎöÒ»¸öXMLÎļþÖеÄÊý¾Ý¡£
1¡¢Types.xml£¨ÏÔʾ¼ªËûµÄÀà±ð£©
<?xml version="1.0" encoding="UTF-8"?>
<types>
<name>µç¼ªËû
<music>ÍæÒ¡¹ö</music>
</name>
......

[HTML±à¼­Æ÷]C#±àдµÄHTML±à¼­Æ÷£ºÔ­Àíƪ

×÷Õߣº¹â½ÅѾ˼¿¼ ʱ¼ä£º12/23/2009 1:51:00 PM
Ò»¿ªÊ¼¾Í¾õµÃHTML±à¼­Æ÷ÕâÍæÒâÓ¦¸ÃÊǺܸßÉîĪ²âµÄ¡£ËæËæ±ã±ã¾ÍÏëÕûÒ»¸öÓ¦¸Ã²»ÊÇÒ»¼þÈÝÒ×µÄÊÂÇé¡£ºóÀ´¶ÔWebBrowser¿Ø¼þÓÐÁËһЩÁ˽⣬²»¹ý¶¼ÊǺܷôdzµÄÁ˽⡣ֻ֪µÀÓÃÕâ¸ö¿Ø¼þ¾ÍÄܹ»ÔÚ×Ô¼ºµÄ³ÌÐòÖиãÒ»¸öWEBä¯ÀÀÆ÷Ö®ÀàµÄ¶«Î÷£¬´ÓÀ´Ã»ÓÐÏë¹ýHTML±à¼­Æ÷Ò²¿ÉÒÔʹÓÃÕâ¸ö¿Ø¼þÀ´ÊµÏ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ