Reputation: 151
Please,
When parsing RSS feed, there is name space with colon like: "content:encoded" and i cant get text value from it.
Found some explanation with iterating XML items (link), but that I cant use, must use known name and then grab the value.
Is there any way to grab the value?
Upvotes: 2
Views: 1046
Reputation: 322
Look for something like the following namespace detail in the starting of the xml document, or parse it programatically :
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
>
Then you can use
var url ="http://blog.com/feed";
var response = UrlFetchApp.fetch(url);
var xml = Xml.parse(response.getContentText(), false);
var itemArray = xml.getElement().getElement("channel").getElements("item");
//Use the URI from namespace details below (Example for <content:encoded>)
var data = itemArray[0].getElement("http://purl.org/rss/1.0/modules/content/","encoded").getText();
Upvotes: 1