LINQ to XML Quick Brain Dump
2009-8-26 5:53:00来源:Asp.net
LINQ to XML is a simple toolset that allows developers to easily interact with XML, whether it be in file form of on the wire in string form.
Write to an XML file
There are a few methods within the System.Xml.Linq namespace which make this interaction a breeze. The four main ones are:-
- XDocument – Method which creates the XML document
- XDeclaration – Allows you to set the declaration at the top of the file.
- XElement – Creates a hierarchical element structure
- XAttribute – Creates any attributes related to an element.
The following code shows a very simple way to generate an XML document for members of a club.
1: Member[] members = new[] {
2: new Member{Age = 33, FullName = "John Havers", Title = "Mr"},
3: new Member{Age = 28, FullName = "Robin Southgate", Title = "Mrs"},
4: new Member{Age = 45, FullName = "Paul Chatwell", Title = "Mr"},
5: };
6:
7: XDocument doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
8: new XElement("members",
9: from member in members
10: select new XElement("member",
11: new XAttribute("age", member.Age),
12: new XAttribute("title", member.Title),
-
Web页面的数据导出excel时的格式问题
2007-2-6 16:42:00摘要: 当我们把web页面上的数据导成excel形式时,有时候我们的数据需要以特定的格式呈现出来,这时候我们就需要给cell添加一些样式规格信息 阅读全文 today 2007-02-0
Windows 7 – Fun with VHD
2010-4-12 8:08:00I’m teaching about TFS 2008 next week and I wanted to use TFS in a virtualized environment so I dow
相同类型的每个对象大小都是一样的吗?
2009-11-30 17:34:00阅读: 721 评论: 20 作者: Jeffrey Zhao 发表于 2009-11-30 14:09 原文链接 快速回答:“相同(引用)类型的每个对象大小都是一样的吗?”其实个问题对于
FIT and DDD in Edmonton
2007-7-10 14:43:00Im giving a talk to the Edmonton .NET Users Group at the end of the month (man how time flies) ab
Twitter API - Submit a post in C#
2009-3-25 21:33:00I used C# and WCF, but I could have just as easily used an ASMX web service. This code is fairly si
包氏波动思想
2009-10-14 2:31:00摘要: MVP模式最后一篇,讲解WPF/Silverlight的另类编程方式。 作者资料: 包建强 我的主页 个人资料 我的闪存 与我联系 -----------
基于行数预测的长文章分页
2009-5-13 3:49:00说句老实话,我是个不大习惯写博的主,而且本次写博目的是想过来发个小广告,哈哈,都是园子里的兄弟不要拿砖头扔我 园子里的兄弟时间都是很宝贵的.为了大家消消火,少让大家过来扔砖头.所以就把最近项目
通过U盘绕过密码登录
2009-8-8 1:23:00有许多朋友还在为忘记XP登陆密码不能进入系统而烦恼,现在我就来给你带来解决的方法。 所需工具 1.U盘一个 2.USBoot 3.winrar 这个方法
对asp.net开发中分层的理解
2012-8-30 0:22:00从一开始接触asp.net到现在算来也有几个年头了,刚开始学C#的时候,压根不知道分层的概念,后来有了一些了解之后,发现大家都在谈分层,但因为当时没有做过什么项目,看到别人对分层的讨论总是知之然而不
0自动转型到DBNull.Value引发的错误
2007-6-24 22:06:00我们写程序的,难免要和数据库进行打交道,存储过程的参数也是在编程中经常要用到的. 但在存储过程参数中,如果有 int 型的参数,我一般习惯于这样写: create PROCEDUR