<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>进化的测试 &#187; XML</title>
	<atom:link href="http://magustest.com/blog/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://magustest.com/blog</link>
	<description>关注软件测试，白盒测试，自动化测试，性能测试</description>
	<lastBuildDate>Wed, 02 Jun 2010 16:12:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>介绍一个格式化XML文档（自动缩进）的工具</title>
		<link>http://magustest.com/blog/computer/formatting-xml-auto-indent/</link>
		<comments>http://magustest.com/blog/computer/formatting-xml-auto-indent/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 02:27:08 +0000</pubDate>
		<dc:creator>magus</dc:creator>
				<category><![CDATA[计算机技术]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://magustest.com/blog/?p=580</guid>
		<description><![CDATA[有时候会遇到这样的一种情况，我们的数据以XML格式发送HTTP请求到服务器，然后服务器的相应也是XML格式的数据，那么我们看这堆XML数据的时候就会比较费劲，因为这些XML的显示格式是乱的，也就是没有做缩进的。网上有好几种方法可以对XML文档进行缩进输出。现在介绍一个免费的工具：Firstobject&#8217;s free XML editor。该工具用C++编写，短小精悍，格式化XML文档起来也非常快，它可以帮我们格式化XML文档，实现自动缩进，提高工作效率。 Share and Enjoy: No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>有时候会遇到这样的一种情况，我们的数据以XML格式发送HTTP请求到服务器，然后服务器的相应也是XML格式的数据，那么我们看这堆XML数据的时候就会比较费劲，因为这些XML的显示格式是乱的，也就是没有做缩进的。网上有好几种方法可以对XML文档进行缩进输出。现在介绍一个免费的工具：<a href="http://www.firstobject.com/dn_editor.htm" target="_blank">Firstobject&#8217;s free XML editor</a>。该工具用C++编写，短小精悍，格式化XML文档起来也非常快，它可以帮我们格式化XML文档，实现自动缩进，提高工作效率。</p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://magustest.com/blog/feed/" title="RSS"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<img src="http://magustest.com/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<img src="http://magustest.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<img src="http://magustest.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmagustest.com%2Fblog%2Fcomputer%2Fformatting-xml-auto-indent%2F&amp;t=%E4%BB%8B%E7%BB%8D%E4%B8%80%E4%B8%AA%E6%A0%BC%E5%BC%8F%E5%8C%96XML%E6%96%87%E6%A1%A3%EF%BC%88%E8%87%AA%E5%8A%A8%E7%BC%A9%E8%BF%9B%EF%BC%89%E7%9A%84%E5%B7%A5%E5%85%B7" title="Facebook"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fmagustest.com%2Fblog%2Fcomputer%2Fformatting-xml-auto-indent%2F&title=%E4%BB%8B%E7%BB%8D%E4%B8%80%E4%B8%AA%E6%A0%BC%E5%BC%8F%E5%8C%96XML%E6%96%87%E6%A1%A3%EF%BC%88%E8%87%AA%E5%8A%A8%E7%BC%A9%E8%BF%9B%EF%BC%89%E7%9A%84%E5%B7%A5%E5%85%B7" title="豆瓣"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/douban.png" title="豆瓣" alt="豆瓣" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fmagustest.com%2Fblog%2Fcomputer%2Fformatting-xml-auto-indent%2F&title=%E4%BB%8B%E7%BB%8D%E4%B8%80%E4%B8%AA%E6%A0%BC%E5%BC%8F%E5%8C%96XML%E6%96%87%E6%A1%A3%EF%BC%88%E8%87%AA%E5%8A%A8%E7%BC%A9%E8%BF%9B%EF%BC%89%E7%9A%84%E5%B7%A5%E5%85%B7&n=1" title="豆瓣九点"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/douban9.png" title="豆瓣九点" alt="豆瓣九点" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.friendfeed.com/share?title=%E4%BB%8B%E7%BB%8D%E4%B8%80%E4%B8%AA%E6%A0%BC%E5%BC%8F%E5%8C%96XML%E6%96%87%E6%A1%A3%EF%BC%88%E8%87%AA%E5%8A%A8%E7%BC%A9%E8%BF%9B%EF%BC%89%E7%9A%84%E5%B7%A5%E5%85%B7&amp;link=http%3A%2F%2Fmagustest.com%2Fblog%2Fcomputer%2Fformatting-xml-auto-indent%2F" title="FriendFeed"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<img src="http://magustest.com/blog/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fmagustest.com%2Fblog%2Fcomputer%2Fformatting-xml-auto-indent%2F&amp;title=%E4%BB%8B%E7%BB%8D%E4%B8%80%E4%B8%AA%E6%A0%BC%E5%BC%8F%E5%8C%96XML%E6%96%87%E6%A1%A3%EF%BC%88%E8%87%AA%E5%8A%A8%E7%BC%A9%E8%BF%9B%EF%BC%89%E7%9A%84%E5%B7%A5%E5%85%B7" title="Live"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<img src="http://magustest.com/blog/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://shuqian.qq.com/post?jumpback=1&title=%E4%BB%8B%E7%BB%8D%E4%B8%80%E4%B8%AA%E6%A0%BC%E5%BC%8F%E5%8C%96XML%E6%96%87%E6%A1%A3%EF%BC%88%E8%87%AA%E5%8A%A8%E7%BC%A9%E8%BF%9B%EF%BC%89%E7%9A%84%E5%B7%A5%E5%85%B7&uri=http%3A%2F%2Fmagustest.com%2Fblog%2Fcomputer%2Fformatting-xml-auto-indent%2F" title="QQ书签"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/qq.png" title="QQ书签" alt="QQ书签" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=%E4%BB%8B%E7%BB%8D%E4%B8%80%E4%B8%AA%E6%A0%BC%E5%BC%8F%E5%8C%96XML%E6%96%87%E6%A1%A3%EF%BC%88%E8%87%AA%E5%8A%A8%E7%BC%A9%E8%BF%9B%EF%BC%89%E7%9A%84%E5%B7%A5%E5%85%B7%20-%20http%3A%2F%2Fmagustest.com%2Fblog%2Fcomputer%2Fformatting-xml-auto-indent%2F" title="Twitter"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://magustest.com/blog/computer/formatting-xml-auto-indent/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>用XSD自动生成XML对应的.NET实体类</title>
		<link>http://magustest.com/blog/net/automatic-generate-xml-instance-by-using-xsd/</link>
		<comments>http://magustest.com/blog/net/automatic-generate-xml-instance-by-using-xsd/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 07:34:41 +0000</pubDate>
		<dc:creator>magus</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XmlSerializer]]></category>
		<category><![CDATA[xsd]]></category>

		<guid isPermaLink="false">http://magustest.com/blog/?p=138</guid>
		<description><![CDATA[在做测试的过程中，测试数据会保存到一个XML文件里面，很多时候还是先有测试数据(XML)，后面才会去做测试。在C#里面，读取XML的方法有很多，最近用了一下XmlSerializer，感觉非常爽！ 自己先编一个XML文件，也就是测试数据： &#160; Magus open5555 &#160; 29 30 &#160; 77 21 然后利用XSD.EXE工具自动生成一个相应的实例类，不用自己编了~，输入命令 xsd XMLFile1.xml 这样会默认生成一个XMLFile1.xsd文件，然后再根据这个xsd文件来生成相应的C#实例类 xsd XMLFile1.xsd /c 默认会生成一个XMLFile1.cs的实例类 using System.Xml.Serialization; &#160; &#91;System.SerializableAttribute&#40;&#41;&#93; &#91;System.Xml.Serialization.XmlRoot&#40;&#41;&#93; public partial class Config &#123; &#160; private string userNameField; &#160; private string passwordField; &#160; private ConfigData&#91;&#93; dataField; &#160; /// &#91;System.Xml.Serialization.XmlElementAttribute&#40;Form=System.Xml.Schema.XmlSchemaForm.Unqualified&#41;&#93; public string UserName &#123; get &#123; return this.userNameField; &#125; set &#123; [...]


Related posts:<ol><li><a href='http://magustest.com/blog/whiteboxtesting/beginning-nmock/' rel='bookmark' title='Permanent Link: NMock2入门经验'>NMock2入门经验</a></li>
<li><a href='http://magustest.com/blog/net/aspnet-web-config-priority/' rel='bookmark' title='Permanent Link: ASP.NET中配置文件web.config的优先级'>ASP.NET中配置文件web.config的优先级</a></li>
<li><a href='http://magustest.com/blog/whiteboxtesting/three-different-test-fixture-setup-approach/' rel='bookmark' title='Permanent Link: 单元测试中三种准备Test Fixture的方法比较'>单元测试中三种准备Test Fixture的方法比较</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>在做测试的过程中，测试数据会保存到一个XML文件里面，很多时候还是先有测试数据(XML)，后面才会去做测试。在C#里面，读取XML的方法有很多，最近用了一下XmlSerializer，感觉非常爽！</p>
<p>自己先编一个XML文件，也就是测试数据：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
    Magus
    open5555
&nbsp;
      29
      30
&nbsp;
      77
      21</pre></div></div>

<p><span id="more-138"></span><br />
然后利用XSD.EXE工具自动生成一个相应的实例类，不用自己编了~，输入命令</p>
<p>xsd XMLFile1.xml</p>
<p>这样会默认生成一个XMLFile1.xsd文件，然后再根据这个xsd文件来生成相应的C#实例类</p>
<p>xsd XMLFile1.xsd /c</p>
<p>默认会生成一个XMLFile1.cs的实例类</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Xml.Serialization</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #000000;">&#91;</span><span style="color: #000000;">System</span>.<span style="color: #0000FF;">SerializableAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlRoot</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> Config <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> userNameField<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> passwordField<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> ConfigData<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> dataField<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">///</span>
    <span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlElementAttribute</span><span style="color: #000000;">&#40;</span>Form<span style="color: #008000;">=</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span>.<span style="color: #0000FF;">Schema</span>.<span style="color: #0000FF;">XmlSchemaForm</span>.<span style="color: #0000FF;">Unqualified</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> UserName <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">userNameField</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">userNameField</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">///</span>
    <span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlElementAttribute</span><span style="color: #000000;">&#40;</span>Form<span style="color: #008000;">=</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span>.<span style="color: #0000FF;">Schema</span>.<span style="color: #0000FF;">XmlSchemaForm</span>.<span style="color: #0000FF;">Unqualified</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Password <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">passwordField</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">passwordField</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">///</span>
    <span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlElementAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Data&quot;</span>, Form<span style="color: #008000;">=</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span>.<span style="color: #0000FF;">Schema</span>.<span style="color: #0000FF;">XmlSchemaForm</span>.<span style="color: #0000FF;">Unqualified</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> ConfigData<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> Data <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">dataField</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">dataField</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">///</span>
<span style="color: #000000;">&#91;</span><span style="color: #000000;">System</span>.<span style="color: #0000FF;">SerializableAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlTypeAttribute</span><span style="color: #000000;">&#40;</span>AnonymousType<span style="color: #008000;">=</span><span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> ConfigData <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> manField<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> ladyField<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">///</span>
    <span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlElementAttribute</span><span style="color: #000000;">&#40;</span>Form<span style="color: #008000;">=</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span>.<span style="color: #0000FF;">Schema</span>.<span style="color: #0000FF;">XmlSchemaForm</span>.<span style="color: #0000FF;">Unqualified</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Man <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">manField</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">manField</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">///</span>
    <span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlElementAttribute</span><span style="color: #000000;">&#40;</span>Form<span style="color: #008000;">=</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span>.<span style="color: #0000FF;">Schema</span>.<span style="color: #0000FF;">XmlSchemaForm</span>.<span style="color: #0000FF;">Unqualified</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Lady <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">ladyField</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">ladyField</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">///</span>
<span style="color: #000000;">&#91;</span><span style="color: #000000;">System</span>.<span style="color: #0000FF;">SerializableAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlTypeAttribute</span><span style="color: #000000;">&#40;</span>AnonymousType<span style="color: #008000;">=</span><span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlRootAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Namespace</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;&quot;</span>, IsNullable<span style="color: #008000;">=</span><span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> NewDataSet <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> Config<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> itemsField<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">///</span>
    <span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span>.<span style="color: #0000FF;">Serialization</span></span>.<span style="color: #0000FF;">XmlElementAttribute</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Config&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> Config<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> Items <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">itemsField</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">itemsField</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>然后把XMLFile1.cs和XMLFile1.xml拷到项目底下就可以用了~非常方便~</p>
<p>用的时候：</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">XmlSerializer xs <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XmlSerializer<span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>Config<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
FileStream fs <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FileStream<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;XMLFile1.xml&quot;</span>, FileMode.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
Config config <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>Config<span style="color: #000000;">&#41;</span>xs.<span style="color: #0000FF;">Deserialize</span><span style="color: #000000;">&#40;</span>fs<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #FF0000;">String</span> name <span style="color: #008000;">=</span> config.<span style="color: #0000FF;">UserName</span></pre></div></div>




Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://magustest.com/blog/feed/" title="RSS"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<img src="http://magustest.com/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F&amp;title=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB&amp;bodytext=%E5%9C%A8%E5%81%9A%E6%B5%8B%E8%AF%95%E7%9A%84%E8%BF%87%E7%A8%8B%E4%B8%AD%EF%BC%8C%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%E4%BC%9A%E4%BF%9D%E5%AD%98%E5%88%B0%E4%B8%80%E4%B8%AAXML%E6%96%87%E4%BB%B6%E9%87%8C%E9%9D%A2%EF%BC%8C%E5%BE%88%E5%A4%9A%E6%97%B6%E5%80%99%E8%BF%98%E6%98%AF%E5%85%88%E6%9C%89%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%28XML%29%EF%BC%8C%E5%90%8E%E9%9D%A2%E6%89%8D%E4%BC%9A%E5%8E%BB%E5%81%9A%E6%B5%8B%E8%AF%95%E3%80%82%E5%9C%A8C%23%E9%87%8C%E9%9D%A2%EF%BC%8C%E8%AF%BB%E5%8F%96XML%E7%9A%84%E6%96%B9%E6%B3%95%E6%9C%89%E5%BE%88%E5%A4%9A%EF%BC%8C%E6%9C%80%E8%BF%91%E7%94%A8%E4%BA%86%E4%B8%80%E4%B8%8BXmlSerializer%EF%BC%8C%E6%84%9F%E8%A7%89%E9%9D%9E%E5%B8%B8%E7%88%BD%EF%BC%81%0A%0A%E8%87%AA%E5%B7%B1" title="Digg"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F&amp;title=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB&amp;notes=%E5%9C%A8%E5%81%9A%E6%B5%8B%E8%AF%95%E7%9A%84%E8%BF%87%E7%A8%8B%E4%B8%AD%EF%BC%8C%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%E4%BC%9A%E4%BF%9D%E5%AD%98%E5%88%B0%E4%B8%80%E4%B8%AAXML%E6%96%87%E4%BB%B6%E9%87%8C%E9%9D%A2%EF%BC%8C%E5%BE%88%E5%A4%9A%E6%97%B6%E5%80%99%E8%BF%98%E6%98%AF%E5%85%88%E6%9C%89%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%28XML%29%EF%BC%8C%E5%90%8E%E9%9D%A2%E6%89%8D%E4%BC%9A%E5%8E%BB%E5%81%9A%E6%B5%8B%E8%AF%95%E3%80%82%E5%9C%A8C%23%E9%87%8C%E9%9D%A2%EF%BC%8C%E8%AF%BB%E5%8F%96XML%E7%9A%84%E6%96%B9%E6%B3%95%E6%9C%89%E5%BE%88%E5%A4%9A%EF%BC%8C%E6%9C%80%E8%BF%91%E7%94%A8%E4%BA%86%E4%B8%80%E4%B8%8BXmlSerializer%EF%BC%8C%E6%84%9F%E8%A7%89%E9%9D%9E%E5%B8%B8%E7%88%BD%EF%BC%81%0A%0A%E8%87%AA%E5%B7%B1" title="del.icio.us"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F&amp;t=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB" title="Facebook"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F&title=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB" title="豆瓣"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/douban.png" title="豆瓣" alt="豆瓣" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.douban.com/recommend/?url=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F&title=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB&n=1" title="豆瓣九点"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/douban9.png" title="豆瓣九点" alt="豆瓣九点" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.friendfeed.com/share?title=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB&amp;link=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F" title="FriendFeed"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/friendfeed.png" title="FriendFeed" alt="FriendFeed" class="sociable-hovers" /></a>
	<img src="http://magustest.com/blog/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F&amp;title=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB" title="Live"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://ping.fm/ref/?link=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F&amp;title=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB&amp;body=%E5%9C%A8%E5%81%9A%E6%B5%8B%E8%AF%95%E7%9A%84%E8%BF%87%E7%A8%8B%E4%B8%AD%EF%BC%8C%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%E4%BC%9A%E4%BF%9D%E5%AD%98%E5%88%B0%E4%B8%80%E4%B8%AAXML%E6%96%87%E4%BB%B6%E9%87%8C%E9%9D%A2%EF%BC%8C%E5%BE%88%E5%A4%9A%E6%97%B6%E5%80%99%E8%BF%98%E6%98%AF%E5%85%88%E6%9C%89%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%28XML%29%EF%BC%8C%E5%90%8E%E9%9D%A2%E6%89%8D%E4%BC%9A%E5%8E%BB%E5%81%9A%E6%B5%8B%E8%AF%95%E3%80%82%E5%9C%A8C%23%E9%87%8C%E9%9D%A2%EF%BC%8C%E8%AF%BB%E5%8F%96XML%E7%9A%84%E6%96%B9%E6%B3%95%E6%9C%89%E5%BE%88%E5%A4%9A%EF%BC%8C%E6%9C%80%E8%BF%91%E7%94%A8%E4%BA%86%E4%B8%80%E4%B8%8BXmlSerializer%EF%BC%8C%E6%84%9F%E8%A7%89%E9%9D%9E%E5%B8%B8%E7%88%BD%EF%BC%81%0A%0A%E8%87%AA%E5%B7%B1" title="Ping.fm"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://shuqian.qq.com/post?jumpback=1&title=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB&uri=http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F" title="QQ书签"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/qq.png" title="QQ书签" alt="QQ书签" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=%E7%94%A8XSD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90XML%E5%AF%B9%E5%BA%94%E7%9A%84.NET%E5%AE%9E%E4%BD%93%E7%B1%BB%20-%20http%3A%2F%2Fmagustest.com%2Fblog%2Fnet%2Fautomatic-generate-xml-instance-by-using-xsd%2F" title="Twitter"><img src="http://magustest.com/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/>

<p>Related posts:<ol><li><a href='http://magustest.com/blog/whiteboxtesting/beginning-nmock/' rel='bookmark' title='Permanent Link: NMock2入门经验'>NMock2入门经验</a></li>
<li><a href='http://magustest.com/blog/net/aspnet-web-config-priority/' rel='bookmark' title='Permanent Link: ASP.NET中配置文件web.config的优先级'>ASP.NET中配置文件web.config的优先级</a></li>
<li><a href='http://magustest.com/blog/whiteboxtesting/three-different-test-fixture-setup-approach/' rel='bookmark' title='Permanent Link: 单元测试中三种准备Test Fixture的方法比较'>单元测试中三种准备Test Fixture的方法比较</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://magustest.com/blog/net/automatic-generate-xml-instance-by-using-xsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
