<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forum — Consuming REST response (VB.NET application)]]></title>
		<link>https://forums.nbn.org.uk/viewtopic.php?id=5571</link>
		<atom:link href="https://forums.nbn.org.uk/extern.php?action=feed&amp;tid=5571&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Consuming REST response (VB.NET application).]]></description>
		<lastBuildDate>Tue, 02 Sep 2014 16:18:02 +0000</lastBuildDate>
		<generator>PunBB 1.4.6</generator>
		<item>
			<title><![CDATA[Consuming REST response (VB.NET application)]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=21084#p21084</link>
			<description><![CDATA[<p>I doubt anyone other than me is actually trying to do this but just in case!</p><p>I am converting the Gateway REST response to an XML then transforming the XML using an XSL (transformation stylesheet).<br />I&#039;ve just succeed in putting together a stylesheet that successfully converts the REST XML response into a csv, it should be usable by anyone and it&#039;s just so damn beautiful i had to share it!</p><p>You&#039;ll notice i am currently omitting the site key and taxon authority fields. This is because they are not always returned with a record and it was leading to file misalignment. Once i figure out how to include the node even when absent i&#039;ll post an update. </p><div class="codebox"><pre><code> &lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
&lt;xsl:output omit-xml-declaration=&quot;yes&quot; method=&quot;text&quot; encoding=&quot;UTF-8&quot; /&gt;

&lt;xsl:template match=&quot;@*|node()&quot;&gt;
    &lt;xsl:copy&gt;
        &lt;xsl:apply-templates select=&quot;@*|node()&quot;/&gt;
    &lt;/xsl:copy&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match=&quot;/*&quot;&gt; &lt;!-- add headers to sheet --&gt;
&lt;xsl:for-each select=&quot;*[1]/*[not(self::siteKey)][not(self::pTaxonAuthority)]&quot;&gt;
&lt;xsl:text&gt;&quot;&lt;/xsl:text&gt;
&lt;xsl:value-of select=&quot;name()&quot;/&gt;
&lt;xsl:text&gt;&quot;&lt;/xsl:text&gt;
&lt;xsl:if test=&quot;position() != last()&quot;&gt;
    &lt;xsl:value-of select=&quot;&#039;,&#039;&quot;/&gt;
&lt;/xsl:if&gt;
&lt;/xsl:for-each&gt;
&lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt;
&lt;xsl:apply-templates/&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match=&quot;TaxonObservation&quot;&gt; &lt;!-- add values under headers --&gt;
  &lt;xsl:for-each select=&quot;*[not(self::siteKey)][not(self::pTaxonAuthority)]&quot;&gt;
  &lt;xsl:text&gt;&quot;&lt;/xsl:text&gt;
   &lt;xsl:value-of select=&quot;.&quot;/&gt;
   &lt;xsl:text&gt;&quot;&lt;/xsl:text&gt;
   &lt;xsl:if test=&quot;position() != last()&quot;&gt;
    &lt;xsl:value-of select=&quot;&#039;,&#039;&quot;/&gt;
   &lt;/xsl:if&gt;
  &lt;/xsl:for-each&gt;
  &lt;xsl:text&gt;&amp;#10;&lt;/xsl:text&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match=&quot;@siteKey&quot; /&gt;
&lt;xsl:template match=&quot;@pTaxonAuthority&quot; /&gt;

&lt;/xsl:stylesheet&gt;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (BDeed)]]></author>
			<pubDate>Tue, 02 Sep 2014 16:18:02 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=21084#p21084</guid>
		</item>
	</channel>
</rss>
