I have created a simple piece of code to fetch news from an RSS page. Below is the code snippet:
this.loadRecentNews = function loadRecentNews() {
$.get("http://rss.nytimes.com/services/xml/rss/nyt/GlobalHome.xml", function (data) {
$(data).find("item").each(function () {
var el = $(this);
console.log("------------------------");
console.log("Title : " + el.find("title").text());
console.log("Link : " + el.find("link").text());
console.log("Description: " + el.find("description").text());
console.log("Date: " + el.find("pubDate").text());
});
});
};
Below is the output:
Title : Example of title
Link : http://www.example.com
Description : Example of <<bb>>Description</b> containing <> tag..
Date : Example of date
The challenge I am facing is that I would like to only extract the text content from the Description field in order to create a new JSON object containing this extracted text.
Is there a way for me to extract only the text without the <> values?