RSS Feed

Category
Topics
Events
E Books
Guide Books
Visit Thailand

To get RSS content, you can use this script.

Reading RSS with PHP

<?php
$domOBJ = new DOMDocument();
$domOBJ->load("https://www.thailand.go.th/useful-rss");//XML page URL

$content = $domOBJ- >getElementsByTagName("item");

foreach( $content as $data )
{
    $title = $data->getElementsByTagName("title")->item(0)->nodeValue;
    $link = $data->getElementsByTagName("link")->item(0)->nodeValue;
    echo "$title :: $link";
}
?>

Reading RSS with ASP

using ReadRSSFeed.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using System.Xml.Linq;

namespace ReadRSSFeed.Controllers
{
    public class RSSFeedController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(string RSSURL)
        {
            WebClient wclient = new WebClient();
            string RSSData=wclient.DownloadString(RSSURL);

            XDocument xml = XDocument.Parse(RSSData);
            var RSSFeedData = (from x in xml.Descendants("item")
                                select new RSSFeed
                                {
                                    Title = ((string)x.Element("title")),
                                    Link = ((string)x.Element("link")),
                                    Description = ((string)x.Element("description")),
                                    PubDate = ((string)x.Element("pubDate"))
                                });
            ViewBag.RSSFeed = RSSFeedData;
            ViewBag.URL = RSSURL;
            return View();
        }
    }
}

Reading RSS with PYTHON

import feedparser

NewsFeed = feedparser.parse("https://www.thailand.go.th/useful-rss")

entry = NewsFeed.entries[1]

print entry.published
print "******"
print entry.summary
print "------News Link--------"
print entry.link
Copyright 2022, The Government Public Relations Department
Web Traffic Statistics : 20,835,267