Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6248223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:01:04+00:00 2026-05-24T13:01:04+00:00

I got a problem regarding parsing XML data. I have divided my program into

  • 0

I got a problem regarding parsing XML data. I have divided my program into 3 different java files, each containing a class. One of them is rssparser.java. This file holds a function called iterateRSSFeed(String URL), this function returns a string containing the parsed description tag. In my main.java files where my main method is, I call this iterateRSSFeed function this way:

rssparser r = new rssparser();
String description = r.iterateRSSFeed();

And then I am planning to add this String to a JLabel, this way:

JLabel news = new JLabel(description);

which obviously works great, my program runs. BUT there are more description tags in my XML file, the JLabel only contains one(1) parsed description tag. I should say that my return statement in the iterateRSSFeed function is “packed” in a for-loop, which in my head should return all of the description tags. But no.

Please ask if something is uncleared or showing of the source code is a better way to provide a solution to my answer. Thanks in advance! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:01:07+00:00Added an answer on May 24, 2026 at 1:01 pm

    When Java executes a return statement, it will leave the method, and not continue running the loop.

    If you want to return multiple values from a method, you have to put them in some object grouping them together. Normally one would use a List<String> as return type.

    Then your loop will fill the list, and the return statement (after the loop) can return the whole list at once.

    If you want to have one large string instead of multiple ones, you’ll have to merge them into one.
    The easiest would be to simply use the .toString() method on the list, this will give (if you are using the default list implementations) something like [element1, element2, element3].

    If you don’t like the [,], you could simply concatenate them:

    List<String> list = r.iterateRSSFeed();
    StringBuilder b = new StringBuilder();
    for(String s : list) {
       b.append(s);
    }
    String description = b.toString();
    

    This will give element1element2element3.

    As Java’s JLabel has some rudimentary HTML support, you could also use this to format your list as a list:

    List<String> list = r.iterateRSSFeed();
    StringBuilder b = new StringBuilder();
    b.append("<html><ul>");
    for(String s : list) {
       b.append("<li>");
       b.append(s);
       b.append("</li>");
    }
    b.append("</ul>");
    String description = b.toString();
    

    The result will be <html><ul><li>element1</li><li>element2</li><li>element3</li></ul>, which will be formatted by the JLabel as something like this:

    • element1
    • element2
    • element3
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got a problem regarding how to assign a java script variable to a
I've got a problem where I have a .co.uk domain of which I am
I've got a problem similar to,but subtly different from, that described here (Loading assemblies
I have got the following problem since the server has safe mode turned on,
i got a weird problem regarding egrep and pipe I tried to filter a
I have a problem regarding StartUp Url in WPF. I have a LoginView.xaml and
Regarding my previous problem that is now fixed, I got another problem with the
I'm building a system for reading emails in C#. I've got a problem parsing
I have a problem regarding to the software deployment. We're using JBoss 4.2.3. Please
I've got a problem scenario w.r.t data cyphering or encryption/decryption in SQL Server 2005.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.