This parser utilizes the XML library built into R to extract valuable fields, convert them into a data frame, and eventually visualize it in the form of a table.
data source : http://feeds.bbci.co.uk/news/world/asia/rss.xml
# Load required library "XML"
library(XML)
# Read source from url
doc = xmlInternalTreeParse("http://feeds.bbci.co.uk/news/world/asia/rss.xml")
# Parse desired values in tags into respective lists
items = getNodeSet(doc, "//channel/item")
titles = lapply(items, xpathApply, ".//title", xmlValue)
descriptions = lapply(items, xpathApply, ".//description", xmlValue)
links = lapply(items, xpathApply, ".//link", xmlValue)
dates = lapply(items, xpathApply, ".//pubDate", xmlValue)
# Remove unnecessary pointers in lists
titles = unlist(titles)
descriptions = unlist(descriptions)
links = unlist(links)
dates = unlist(dates)
# Bind resulting lists to a data frame
result = data.frame(Title=titles, Description=descriptions, Links=links, Dates=dates)
summary(result)
## Title
## 'Smoking' elephant in India baffles experts : 1
## #MeToo movement takes hold in South Korea : 1
## A day in the life of India's 'tuberculosis warrior' : 1
## Actor Anthony Wong finds family who never knew him, after BBC report: 1
## Anthony Wong: Hong Kong actor finds brothers after BBC report : 1
## Australia's indigenous languages have one source, study says : 1
## (Other) :32
## Description
## A report on Hong Kong actor Anthony Wong's search for his father leads him to his long-lost brothers. : 1
## Aboriginal Australians reflect on National Geographic's racism in 1916, and public discourse today. : 1
## After Tillerson's quick exit - who will be part of high-stakes talks with North Korea? : 1
## All indigenous languages can be traced to a mother tongue dubbed Proto-Australian, researchers say. : 1
## Amir Liaquat Hussain is popular with viewers - but has also been accused of inciting hatred and using lewd content.: 1
## Anthony Wong, an award winning actor, had spent decades looking for traces of his British father. : 1
## (Other) :32
## Links
## http://www.bbc.co.uk/news/business-43251862 : 1
## http://www.bbc.co.uk/news/business-43564714 : 1
## http://www.bbc.co.uk/news/entertainment-arts-43515888: 1
## http://www.bbc.co.uk/news/health-43571120 : 1
## http://www.bbc.co.uk/news/newsbeat-43030798 : 1
## http://www.bbc.co.uk/news/stories-43516155 : 1
## (Other) :32
## Dates
## Fri, 16 Mar 2018 04:23:51 GMT: 1
## Fri, 16 Mar 2018 15:45:07 GMT: 1
## Fri, 16 Mar 2018 16:30:03 GMT: 1
## Fri, 16 Mar 2018 22:06:45 GMT: 1
## Fri, 23 Mar 2018 17:21:24 GMT: 1
## Mon, 19 Mar 2018 08:02:23 GMT: 1
## (Other) :32
# Load required library "knitr"
library(knitr)
# Visualize result sets
kable(result)
| Title | Description | Links | Dates |
|---|---|---|---|
| Malala Yousafzai returns to Pakistan for first time since shooting | The Nobel Peace Prize winner was shot and injured by the Taliban in 2012 for daring to go to school. | http://www.bbc.co.uk/news/world-asia-43578604 | Thu, 29 Mar 2018 00:29:51 GMT |
| Trump keen to meet Kim after ‘successful’ China talks | The US president gives a positive reaction to the North Korean leader meeting China’s president. | http://www.bbc.co.uk/news/world-us-canada-43573686 | Wed, 28 Mar 2018 16:01:52 GMT |
| Australian ball-tampering: Darren Lehmann says side must stop ‘butting heads’ | Australia must change their style of play and stop “butting heads” with opponents after the ball tampering scandal, says coach Darren Lehmann. | http://www.bbc.co.uk/sport/cricket/43571509 | Wed, 28 Mar 2018 19:15:17 GMT |
| Man has ‘world’s worst’ super-gonorrhoea | It is the first ever case that is resistant to the main antibiotic treatment. | http://www.bbc.co.uk/news/health-43571120 | Wed, 28 Mar 2018 16:26:26 GMT |
| Win Myint elected new Myanmar president | The close aide of de facto leader Aung San Suu Kyi takes over after his predecessor resigned. | http://www.bbc.co.uk/news/world-asia-43564954 | Wed, 28 Mar 2018 07:11:20 GMT |
| Australia’s indigenous languages have one source, study says | All indigenous languages can be traced to a mother tongue dubbed Proto-Australian, researchers say. | http://www.bbc.co.uk/news/world-australia-43564134 | Wed, 28 Mar 2018 02:01:54 GMT |
| WTO: US-China trade war would have ‘severe’ economic impact | Global growth could fall “quickly” if Washington and Beijing push ahead with tariff threats, warns WTO. | http://www.bbc.co.uk/news/business-43564714 | Wed, 28 Mar 2018 05:24:57 GMT |
| ‘Smoking’ elephant in India baffles experts | It’s the first time a wild elephant has been seen apparently ingesting ash from a fire, experts say. | http://www.bbc.co.uk/news/world-asia-india-43551715 | Tue, 27 Mar 2018 05:43:51 GMT |
| Australia ball-tampering: Steve Smith, David Warner & Cameron Bancroft sent home from SA | Cricket Australia sends captain Steve Smith, vice-captain David Warner and batsman Cameron Bancroft home from South Africa. | http://www.bbc.co.uk/sport/cricket/43543713 | Wed, 28 Mar 2018 09:50:10 GMT |
| Tiangong-1: China space station may fall to Earth ‘in days’ | The defunct station is hurtling towards Earth but chances of it crashing in your garden are slim. | http://www.bbc.co.uk/news/world-asia-china-43551144 | Tue, 27 Mar 2018 07:40:06 GMT |
| Australian ball-tampering: Darren Lehmann ‘truly sorry’ | Australia coach Darren Lehmann speaks to the media for the first time since the ball-tampering incident and says he is “truly sorry” for “letting people down”. | http://www.bbc.co.uk/sport/cricket/43571156 | Wed, 28 Mar 2018 18:36:24 GMT |
| Anthony Wong: Hong Kong actor finds brothers after BBC report | A report on Hong Kong actor Anthony Wong’s search for his father leads him to his long-lost brothers. | http://www.bbc.co.uk/news/world-asia-china-43540148 | Mon, 26 Mar 2018 23:00:18 GMT |
| Mahira Khan: Bollywood ‘never really the aim’ | The Pakistani actress Mahira Khan on the controversy that surrounded the release of her film Raees. | http://www.bbc.co.uk/news/entertainment-arts-43515888 | Mon, 26 Mar 2018 10:20:31 GMT |
| I was expected to marry so I went to Antarctica instead | Meena was raised a ‘good Indian girl’ who was expected to get married, but she’s off to Antarctica. | http://www.bbc.co.uk/news/stories-43516155 | Sun, 25 Mar 2018 00:34:23 GMT |
| Actor Anthony Wong finds family who never knew him, after BBC report | Anthony Wong, an award winning actor, had spent decades looking for traces of his British father. | http://www.bbc.co.uk/news/world-asia-china-43538007 | Mon, 26 Mar 2018 23:00:33 GMT |
| Cricket scandal stings an incredulous nation | In a country where sport is often linked to national identity, allegations of cheating have hit hard. | http://www.bbc.co.uk/news/world-australia-43537767 | Mon, 26 Mar 2018 05:04:40 GMT |
| Pakistan’s first transgender TV anchor | Marvia Malik, a journalism graduate, told the BBC she was moved to tears when she was offered the job. | http://www.bbc.co.uk/news/world-asia-43544146 | Mon, 26 Mar 2018 15:00:44 GMT |
| #MeToo movement takes hold in South Korea | Hundreds of women are speaking out against sexual abuse in South Korea. So can things change? | http://www.bbc.co.uk/news/world-asia-43534074 | Mon, 26 Mar 2018 00:24:40 GMT |
| Formula 1 is back - without the grid girls | As the racing season gets underway, not everyone is happy with the decision to axe grid girls. | http://www.bbc.co.uk/news/newsbeat-43030798 | Sun, 25 Mar 2018 01:11:41 GMT |
| Who sent the wedding gift bomb that killed this newlywed? | He was murdered five days after his wedding - and police have no idea who could have wanted him dead. | http://www.bbc.co.uk/news/world-asia-india-43497820 | Sun, 25 Mar 2018 00:01:18 GMT |
| Australia ball-tampering row: The key questions facing Australian cricket | Who was involved? Are Australia out of control? We try to answer the key questions after Saturday’s ball-tampering. | http://www.bbc.co.uk/sport/cricket/43535282 | Sun, 25 Mar 2018 17:22:42 GMT |
| The evolution of UK-Australia travel into a single flight | The first non-stop journey takes place on Saturday, almost 80 years after it involved 31 stopovers. | http://www.bbc.co.uk/news/world-australia-43453264 | Fri, 23 Mar 2018 17:21:24 GMT |
| A day in the life of India’s ‘tuberculosis warrior’ | On world tuberculosis day, Dr Zarir Udwadia talks about his fight against the deadly disease. | http://www.bbc.co.uk/news/world-asia-india-43456442 | Sat, 24 Mar 2018 00:36:18 GMT |
| Rebuilding your country with retro rock | Kak Channthy’s story of overcoming poverty and hardship inspired people from all around the globe. | http://www.bbc.co.uk/news/world-asia-43482011 | Wed, 21 Mar 2018 09:35:06 GMT |
| The Rohingya children trafficked for sex | Teenage refugee girls are being sold for sex after fleeing conflict in Myanmar, the BBC finds. | http://www.bbc.co.uk/news/world-asia-43469043 | Tue, 20 Mar 2018 22:53:37 GMT |
| Xi Jinping: How China’s president got ahead, in hats | The story of China’s parliament told in hats - and the shock that had some analysts eating theirs. | http://www.bbc.co.uk/news/world-asia-china-43480624 | Tue, 20 Mar 2018 23:20:20 GMT |
| South Africa and the fable of the missing Guptas | The tale of how the Gupta family wormed its way into the heart of South Africa - and then vanished. | http://www.bbc.co.uk/news/world-africa-43485872 | Thu, 22 Mar 2018 02:36:29 GMT |
| The ‘hate speech’ TV anchor teaming up with Imran Khan | Amir Liaquat Hussain is popular with viewers - but has also been accused of inciting hatred and using lewd content. | http://www.bbc.co.uk/news/world-asia-43471552 | Wed, 21 Mar 2018 07:40:14 GMT |
| How China’s government has changed after the NPC | China’s removal of presidential term limits are among some of the biggest reforms outlined at NPC. | http://www.bbc.co.uk/news/world-asia-china-43382135 | Tue, 20 Mar 2018 11:07:47 GMT |
| China’s anti-corruption campaign expands with new agency | It will supervise millions of civil servants - but critics call it a “systemic threat to human rights”. | http://www.bbc.co.uk/news/world-asia-china-43453769 | Tue, 20 Mar 2018 12:33:46 GMT |
| The Kashmiri property rows that date back to British India | Families are still fighting to prove they own property lost when British India was partitioned. | http://www.bbc.co.uk/news/world-asia-india-42820910 | Tue, 20 Mar 2018 01:25:40 GMT |
| The man who has Xi’s ear on China’s economy | One of President Xi’s closest advisers takes control of China’s economic policies and financial issues. | http://www.bbc.co.uk/news/business-43251862 | Mon, 19 Mar 2018 08:02:23 GMT |
| Speaking up about rape in conservative Kazakhstan | In Kazakhstan, victims say relatives and police tell them to stay silent or “leave it with Allah”. | http://www.bbc.co.uk/news/world-asia-43247005 | Sun, 18 Mar 2018 00:29:19 GMT |
| National Geographic apology: ‘We were anticipated to be a dying race’ | Aboriginal Australians reflect on National Geographic’s racism in 1916, and public discourse today. | http://www.bbc.co.uk/news/world-australia-43410584 | Sat, 17 Mar 2018 16:05:13 GMT |
| Have smaller weddings with less food, Uzbeks told | Weddings in Uzbekistan are lavish affairs, some with motorcades and hundreds of guests. | http://www.bbc.co.uk/news/world-asia-43429433 | Fri, 16 Mar 2018 16:30:03 GMT |
| The rock band manager who swapped success for kangaroos | Rae Harvey wrangled some of Australia’s top music acts - now she’s handling vulnerable marsupials. | http://www.bbc.co.uk/news/world-australia-43381511 | Fri, 16 Mar 2018 15:45:07 GMT |
| Who does the US have left to talk to N Korea? | After Tillerson’s quick exit - who will be part of high-stakes talks with North Korea? | http://www.bbc.co.uk/news/world-us-canada-43436038 | Fri, 16 Mar 2018 22:06:45 GMT |
| Nerve agent attacks: How Malaysia responded compared to the UK | Both the UK and Malaysia faced nerve agent attacks on their soil, but they responded very differently. | http://www.bbc.co.uk/news/world-asia-43418069 | Fri, 16 Mar 2018 04:23:51 GMT |