<?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>cat brain.stuff &#62; wordpress &#187; schema</title>
	<atom:link href="http://famvdploeg.com/blog/tag/schema/feed/" rel="self" type="application/rss+xml" />
	<link>http://famvdploeg.com/blog</link>
	<description>A simple look on things</description>
	<lastBuildDate>Fri, 03 Feb 2012 15:09:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Deserializing XML twitter feeds.</title>
		<link>http://famvdploeg.com/blog/2010/07/deserializing-xml-twitter-feeds/</link>
		<comments>http://famvdploeg.com/blog/2010/07/deserializing-xml-twitter-feeds/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 10:08:41 +0000</pubDate>
		<dc:creator>Wytze</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[deserialize]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xsd]]></category>

		<guid isPermaLink="false">http://famvdploeg.com/blog/?p=172</guid>
		<description><![CDATA[1. Use xsd.exe to extract an xsd file from an xml feed. Download a private xml feed for example from &#8220;http://api.twitter.com/1/statuses/user_timeline.xml&#8221; and store it to local disk. Use xsd.exe to generate the xsd. 2. Generate the classes from the xsd file you just generated. xsd.exe yourxsd.xsd /c 3. Add the generated classes to your C# [...]]]></description>
			<content:encoded><![CDATA[<p>1. Use xsd.exe to extract an xsd file from an xml feed.<br />
Download a private xml feed for example from &#8220;http://api.twitter.com/1/statuses/user_timeline.xml&#8221; and store it to local disk. Use xsd.exe to generate the xsd.<br />
2. Generate the classes from the xsd file you just generated.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xsd.exe yourxsd.xsd <span style="color: #000000; font-weight: bold;">/</span>c</pre></div></div>

<p>3. Add the generated classes to your C# project.<br />
4. Time for some fetching here is a short example:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// encode the username/password</span>
<span style="color: #6666cc; font-weight: bold;">string</span> user <span style="color: #008000;">=</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToBase64String</span><span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Text</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Encoding</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UTF8</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetBytes</span><span style="color: #008000;">&#40;</span>username <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;:&quot;</span> <span style="color: #008000;">+</span> password<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
HttpWebRequest request <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>HttpWebRequest<span style="color: #008000;">&#41;</span>WebRequest<span style="color: #008000;">.</span><span style="color: #0000FF;">Create</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://api.twitter.com/1/statuses/user_timeline.xml&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008080; font-style: italic;">// set the method to GET</span>
request<span style="color: #008000;">.</span><span style="color: #0000FF;">Method</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;GET&quot;</span><span style="color: #008000;">;</span>
request<span style="color: #008000;">.</span><span style="color: #0000FF;">ServicePoint</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Expect100Continue</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
<span style="color: #008080; font-style: italic;">// set the authorisation levels</span>
request<span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Authorization&quot;</span>, <span style="color: #666666;">&quot;Basic &quot;</span> <span style="color: #008000;">+</span> user<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
request<span style="color: #008000;">.</span><span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;application/x-www-form-urlencoded&quot;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>HttpWebResponse response <span style="color: #008000;">=</span> request<span style="color: #008000;">.</span><span style="color: #0000FF;">GetResponse</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">as</span> HttpWebResponse<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	XmlSerializer serializer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XmlSerializer<span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>statuses<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	statuses s <span style="color: #008000;">=</span> serializer<span style="color: #008000;">.</span><span style="color: #0000FF;">Deserialize</span><span style="color: #008000;">&#40;</span>response<span style="color: #008000;">.</span><span style="color: #0000FF;">GetResponseStream</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">as</span> statuses<span style="color: #008000;">;</span>
&nbsp;
	listBox1<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Clear</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>statusesStatus status <span style="color: #0600FF; font-weight: bold;">in</span> s<span style="color: #008000;">.</span><span style="color: #0000FF;">status</span><span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		listBox1<span style="color: #008000;">.</span><span style="color: #0000FF;">Items</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>status<span style="color: #008000;">.</span><span style="color: #0000FF;">text</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://famvdploeg.com/blog/2010/07/deserializing-xml-twitter-feeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

