ʹÓÃWriteXml,ReadXmlÐòÁл¯·´ÐòÁл¯DataTable£¨×ªÔØ£©
±¾ÎĽéÉÜʹÓÃʹÓÃWriteXml,ReadXml¶ÔDataTableÐòÁл¯·´ÐòÁл¯,ͬʱ´¦Àí"DataTable ²»Ö§³ÖÀ´×Ô XML µÄ¼Ü¹¹Íƶϡ£"´íÎó.
ÓÉÓÚDataTable±¾Éí¾ÍʵÏÖÁËISerializable, IXmlSerializable½Ó¿Ú.ËùÒÔ±¾Éí¾ÍÖ§³ÖÐòÁл¯·´ÐòÁл¯.
DataTableÊǸöºÜºÃµÄÊý¾ÝÀàÐÍ
1.Êý¾Ý¿âÖеıíÍêÈ«¶ÔÓ¦.
2.Repleater,DataGridµÈ¿Ø¼þ¶¼Ö§³Ö¶ÔËüµÄ°ó¶¨.
3.ÔÚ´úÂëÖÐÑ»·±éÀúÌر𷽱ã.
µ«ÎªÁËÍøÂç´«Êä,»òÕßÀëÏß±£´æ,¾ÍÐèÒªÐòÁл¯·´ÐòÁл¯Îªxml.WriteXml,ReadXml¾ÍÊÇʵÏÖ´ÎÄ¿µÄµÄ.
Ò».ʹÓÃWriteXmlÐòÁл¯DataTable:
×¼±¸Êý¾Ý:
- create table sitemaps
- (
- url varchar(255),
- title varchar(255)
- )
- insert sitemaps
- select 'http://www.it118.org', 'itÖÇ¿âÍø'
- union all
- select 'http://bbs.it118.org', 'itÖÇ¿âÍøÂÛ̳'
C#´¦Àí´úÂë:
- SqlConnection connection = new SqlConnection("Server=localhost;Database=testdb;uid=sa;pwd=sa");
- connection.Open();
- SqlCommand selectCommand = new SqlCommand(string.Format("SELECT * from sitemaps"), connection);
- DataTable dataTable = new DataTable("sitemaps"); //×¢ÒâtableÒ»¶¨ÐèÒªÓÐtablename
- new SqlDataAdapter(selectCommand).Fill(dataTable);
- connection.Close();
- dataTable.WriteXml("d:\\sitemaps.xml");
ÆäÖÐsitemaps.xml:
- <?xml version="1.0" standalone="yes"?>
- <DocumentElement>
- <sitemaps>
- <url>http://www.it118.org</url>
- <title>itÖÇ¿âÍø</title>
- </sitemaps>
- <sitemaps>
- <url>http://bbs.it118.org</url>
- <title>itÖÇ¿âÍøÂÛ̳</title>
- </sitemaps>
- </DocumentElement>
¶þ.ʹÓÃReadXmlÐòÁл¯DataTable:
Èç¹û´úÂëÈçÏÂ:
- DataTable dt = new DataTable();
- dt.ReadXml("d:\\sitemaps.xml");
¾Í»áÌáʾ:DataTable ²»Ö§³ÖÀ´×Ô XML µÄ¼Ü¹¹Íƶϡ£
ÕýÈ·´úÂëÈçÏÂ:
- DataTable dt = new DataTable("sitemaps");
- dt.Columns.Add("url");
- dt.Columns.Add("title");
- dt.ReadXml("d:\\sitemaps.xml");
Èý.Ó¦ÓÃ
ÎÒÔø¾ÓÐÌØÊâÐèÒª.ÔÚ±¾µØʹÓÃWriteXmlÉú³Éxml,´«Êäµ½±ðµÄµØ·½Ê¹ÓÃReadXml¶ÁÈ¡.
ÍƼöÐÅÏ¢
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- Asp.net MVCÔ´Âë·ÖÎö--Model Validation(Se....
- .Net À¬»ø»ØÊÕ»úÖÆÔÀíºÍËã·¨£¨Ò»£©
- .netʵÌåнâ
- ·ÖÎöASP.NET¶ÁÈ¡XMLÎļþ4ÖÖ·½·¨
- »ñÈ¡ÍøÕ¾ËõÂÔͼ´úÂë
- Asp.net ¸ù¾ÝIPµØÖ·»ñÈ¡¿çÍø¶ÎmacµØÖ·º¯Êý¡¾ËѲء¿
- ¹ýÂËÃô¸Ð¹Ø¼ü×Ö¡£
- Éú³ÉÖ¸¶¨Î»ÊýµÄËæ»ú×Ö·û´®
- ¿Í»§¶Ë»ñÈ¡MACµØÖ·£¬µ½·þÎñÆ÷ÑéÖ¤
- ²½²½ÎªÓª .NETÈý²ã¼Ü¹¹½âÎö ¶þ¡¢Êý¾Ý¿âÉè¼Æ
ÆÀÂÛ