1

I've got a file with the RSS feed from a website, and I'd like to know if I had some sort of way to properly display that in my JEditorPane. I've got an XML file that I saved from the page. Is there some sort way to load is it is, or is there some sort of API to do this?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
TheNerdyCoder
  • 184
  • 1
  • 10
  • How do you want it displayed? As a raw dump of the XML or some kind of formatting? – MadProgrammer Jan 05 '13 at 00:10
  • @MadProgrammer I would like to display it with some sort of formatting, if it's possible. – TheNerdyCoder Jan 05 '13 at 00:11
  • You'll need to create and install an [`EditorKit`](http://docs.oracle.com/javase/7/docs/api/javax/swing/text/EditorKit.html) for the content type. – Andrew Thompson Jan 05 '13 at 00:14
  • @AndrewThompson Any one in specific? – TheNerdyCoder Jan 05 '13 at 00:16
  • Any one what? `EditorKit`, content-type? Be specific about what you do not understand. – Andrew Thompson Jan 05 '13 at 00:19
  • @AndrewThompson You told me to use an editor kit, which I have never worked with before. I'm guessing it's way to parse and display the input and show it on the editorpane, but I'm confused about how to use it. Is there an RSS editorkit built it? Where would it be? Or has someone else come up with their own I could use? – TheNerdyCoder Jan 05 '13 at 00:24
  • *"I'm guessing it's way to parse and display the input and show it on the editorpane," Yes. *"Is there an RSS editorkit built it?"* No. You would need something that can pares XML presumably. *"Or has someone else come up with their own I could use?"* A search engine might help there. Search on 'XML+RSS+EditorKit+Java'. – Andrew Thompson Jan 05 '13 at 00:35
  • A related example is examined [here](http://stackoverflow.com/q/10461087/230513). – trashgod Jan 05 '13 at 01:41

1 Answers1

0

You can display the content however you like once it's been extracted from the XML. It might be easiest to create a class to represent individual entries in the RSS feed.

For example:

interface MyRSSEntry {
    String getTitle();
    String getDescription();
    String getLink();
    Date getTimestamp();
    // any other properties of the RSS feed you want to capture in your model and possibly display
}

Then, once you've parsed your xml file into a list of MyRSSEntry instances, you can put the information into your editorPane - there's a few examples online - this one might be simplest to start with, and you can apply more (formatting, etc) once you become more familiar with it.

Krease
  • 15,805
  • 8
  • 54
  • 86