Search This Site

Custom Search

Friday, October 1, 2010

[bloggerDev] Please add to Java GData tutorial: HTML content of blog entries

Hi dev-team,

I'd like to have something being added to the GData/Blogger Java SDK
tutorials added. It took me almost a day to figure out how to retrieve
the HTML content of my blog entry. I saw a number of people looking
for that and therefore I'd like to post the following code, because I
found the answers somewhat not helpful.

GoogleService blogService = new GoogleService("blogger",
"kammerath");
BlogFeed blogFeed = blogService.getFeed(new URL(feedUrl),
BlogFeed.class);

List<BlogEntry> blogEntries = blogFeed.getEntries();
for (int i = 0; i < blogEntries.size(); i++) {
BlogEntry entry = blogEntries.get(i);
ContentItem item = new ContentItem();
item.title = entry.getTitle().getPlainText();
item.text = ((HtmlTextConstruct)
((TextContent)entry.getContent()).getContent()).getHtml();
contentItems.put(item.title, item);
}

Hope this helps someone getting it quicker.

Jan

--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To post to this group, send email to bloggerdev@googlegroups.com.
To unsubscribe from this group, send email to bloggerdev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bloggerdev?hl=en.

No comments:

Post a Comment