Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kyle Goulding 30 posts 192 karma points
    Nov 17, 2016 @ 20:01
    Kyle Goulding
    0

    ATOM Feed in Website

    Hi,

    Is it possible to consume an ATOM feed using partial views, does anyone have any resources or able to point me in the write direction?

    Demo ATOM feed - https://www.gov.uk/government/organisations/public-health-england.atom

    Thanks

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 17, 2016 @ 20:17
    Dennis Aaen
    0

    Hi Kyle,

    Perhaps you could use this package to solve your task.

    https://our.umbraco.org/projects/website-utilities/eyecatch-rss-feed-generator/

    Hope this helps,

    /Dennis

  • Kyle Goulding 30 posts 192 karma points
    Nov 18, 2016 @ 08:55
    Kyle Goulding
    0

    Hi Denis,

    Thanks for providing this, I had been exploring this package, but as far as I could tell it seems to be for creating an RSS/ATOM feedback from the data in my own site. Where as I am looking at bringing in an ATOM feed from an external source.

    I have been playing with the code from the following thread - https://our.umbraco.org/forum/developers/razor/27409-Consume-an-RSS-feed-in-Razor

    Which has allowed me to bring in an RSS feed from BBC News http://feeds.bbci.co.uk/news/uk/rss.xml?edition=uk, but I cannot seem to find anything for an ATOM Feed.

    I wonder whether anyone has been able to do this before using Umbraco?

    Thanks

  • Kyle Goulding 30 posts 192 karma points
    Nov 18, 2016 @ 11:53
    Kyle Goulding
    0

    I have managed to get some of the data for the ATOM FEED to display on the page using the following...

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    <h1>RSS TEST</h1>
    <h2>Page Title: @Umbraco.Field("pageTitle")</h2>
    
    @using System.Xml
    @using System.ServiceModel.Syndication;
    @{
        var feed = SyndicationFeed.Load(new XmlTextReader("https://www.gov.uk/government/organisations/public-health-england.atom"));
    }
    @foreach (var item in feed.Items) {
        <p><br />
                    <hr/>
            <b>Authors:</b> @item.Authors.ToString()<br/>
    
    
            <b>category:</b> @item.Categories.ToString()<br/>   
            <b>content:</b> @item.Content.ToString()<br/>   
            <b>contributor:</b> @item.Contributors.ToString()<br/>
            @*<b>link with rel="edit-media":</b> @item.EditMediaUri.ToString()<br/> 
            <b>link with rel="edit":</b> @item.EditUri.Text<br/>    *@
            <b>id:</b> @item.Id.ToString()<br/> 
            @*<b>xml:lang:</b> @item.Language.ToString()<br/>   *@  
            <b>update:</b> @item.LastUpdatedTime.ToString("F")<br/>     
            <b>link:</b> @item.Links.Text<br/>      
            <b>published:</b> @item.PublishDate.ToString("F")<br/>  
            @*<b>rights:</b> @item.Rights.ToString()<br/>   
            <b>source:</b> @item.Source.ToString()<br/> *@
            <b>summary:</b> @item.Summary.Text<br/> 
            <b>title:</b> @item.Title.Text<br/>
            <b></b><br/>        
        </p>
    }
    

    But I am struggling with the formatting of the elements, I need to map to the Links element so I can add a link back to the original source.

    I am struggling to find out how to obtain the data for this.

  • Kyle Goulding 30 posts 192 karma points
    Nov 21, 2016 @ 16:10
    Kyle Goulding
    100

    If anyone else is struggling with anything similar with ATOM FEEDS below is the code with displays the following:

    • Title
    • Summary
    • Published Date
    • ID
    • Updated Date
    • Item URL

      @using System.Xml @using System.ServiceModel.Syndication; @{ var feed = SyndicationFeed.Load(new XmlTextReader("https://www.gov.uk/government/organisations/public-health-england.atom")); } @foreach (var item in feed.Items) {

          <p><strong>Title: </strong>  @item.Title.Text</p>
          <p><strong>summary: </strong> @item.Summary.Text</p>
      
      
      
      &lt;p&gt;&lt;strong&gt;Published: &lt;/strong&gt; @item.PublishDate.ToString("F")&lt;br/&gt;&lt;/p&gt;
      &lt;p&gt;&lt;strong&gt;id:&lt;/strong&gt; @item.Id.ToString()&lt;/p&gt;
      &lt;p&gt;&lt;strong&gt;update:&lt;/strong&gt; @item.LastUpdatedTime.ToString("F")&lt;br/&gt;&lt;/p&gt;  
      
      
      &lt;p&gt;&lt;strong&gt;Orignial Item URL:&lt;/strong&gt; @item.Links.First().Uri&lt;br/&gt;&lt;/p&gt; 
      
      
       &lt;hr/&gt; 
      

      }

    I have been pulling my hair out with this one so I hope it helps someone else :)

Please Sign in or register to post replies

Write your reply to:

Draft