Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 ²Î¿¼ÊÖ²á1

XML Schema ²Î¿¼ÊÖ²á
XSD ÔªËØ
ÔªËØ
½âÊÍ
all
¹æ¶¨×ÓÔªËØÄܹ»ÒÔÈÎÒâ˳Ðò³öÏÖ£¬Ã¿¸ö×ÓÔªËؿɳöÏÖÁã´Î»òÒ»´Î¡£
annotation
annotation ÔªËØÊÇÒ»¸ö¶¥²ãÔªËØ£¬¹æ¶¨ schema µÄ×¢ÊÍ¡£
any
ʹ´´×÷Õß¿ÉÒÔͨ¹ýδ±» schema ¹æ¶¨µÄÔªËØÀ´À©Õ¹ XML Îĵµ¡£
anyAttribute
Ê ......

XML Schema °ïÖúÎĵµ4

XML Schema import ÔªËØ
¶¨ÒåºÍÓ÷¨
import ÔªËØÓÃÓÚÏòÒ»¸öÎĵµÌí¼Ó´øÓв»Í¬Ä¿±êÃüÃû¿Õ¼äµÄ¶à¸ö schema¡£
ÔªËØÐÅÏ¢
³öÏÖ´ÎÊý
ÎÞÏÞÖÆ
¸¸ÔªËØ
schema
ÄÚÈÝ
annotation
Óï·¨
<import
id=ID
namespace=anyURI
schemaLocation=anyURI
any attributes
>
(annotation?)
< ......

C# Á¬½ÓsqlÊý¾Ý¿â¶Ô access£¬excelµ¼Èëµ¼³ö²Ù×÷


 
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ  czdImport Data£¨µ¼ÈëÊý¾Ý£©¡£
¡¡¡¡¡ ......

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


1£©XmlÎĵµÊ¾Àý£¨xmlsample.xml£©£º
 
Code
<?xml version="1.0" encoding="iso-8859-1" ?>
<music>
  <song title="Oh,girl">
    <artist>The Chi-lites</artist>
    <genre>Soul</genre>
  &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ