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 9155807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:39:32+00:00 2026-06-17T12:39:32+00:00

I have a code with several if/else statements. However, whenever an ‘else’ case is

  • 0

I have a code with several if/else statements. However, whenever an ‘else’ case is thrown, all of the subsequent statements result in ‘else’ too. Here’s the code, i’d appreciate some help please!

public List<Integer> htmlHelper(String arg) throws IOException,
        XPatherException, ParserConfigurationException,
        XPathExpressionException {
    CleanerProperties props = new CleanerProperties();

    props.setTranslateSpecialEntities(true);
    props.setTransResCharsToNCR(true);
    props.setOmitComments(true);

    HtmlCleaner cleaner = new HtmlCleaner(props);
    rootNode = cleaner.clean(arg);


    TagNode tagNode = new HtmlCleaner(props).clean(new URL(
            "http://www.athletics.psu.edu/psustrength/index_rec.asp"));
    org.w3c.dom.Document doc = (org.w3c.dom.Document) new DomSerializer(
            new CleanerProperties()).createDOM(tagNode);

    XPath jpath = XPathFactory.newInstance().newXPath();
    String recinfo = (String) jpath
            .evaluate(

"/html/body/div/div[1]/div/div/table/tbody/tr[3]/td[2]/p[2]/text()",
                    doc, XPathConstants.STRING);
    String recnum = recinfo.replaceAll("\\D+", "");

    if (recnum != null && recnum.length() == 0) {

        recnumint = 500;
        grec = 0;
    } else {
        recnumint = Integer.parseInt(recnum);
        grec = recnumint;
    }

    XPath ipath = XPathFactory.newInstance().newXPath();
    String iminfo = (String) ipath
            .evaluate(

"/html/body/div/div[3]/div/div/table/tbody/tr[2]/td[2]/p[2]/text()",
                    doc, XPathConstants.STRING);
    String imnum = iminfo.replaceAll("\\D+", "");

    if (imnum != null && recnum.length() == 0) {

        imint = 400;
        gim = 0;
    } else {
        imint = Integer.parseInt(imnum);
        gim = imint;
    }

    XPath xpath = XPathFactory.newInstance().newXPath();
    String whiteinfo = (String) xpath
            .evaluate(

"/html/body/div/div[3]/div/div/table/tbody/tr[1]/td[2]/p[2]/text()",
                    doc, XPathConstants.STRING);
    String whitenum = whiteinfo.replaceAll("\\D+", "");

    if (whitenum != null && recnum.length() == 0) {

        whitenumint = 450;
        gwhite = 0;
    } else {
        whitenumint = Integer.parseInt(whitenum);
        gwhite = whitenumint;
    }

    XPath fpath = XPathFactory.newInstance().newXPath();
    String fitinfo = (String) fpath
            .evaluate(

"/html/body/div/div[3]/div/div/table/tbody/tr[4]/td[2]/p[2]/text()",
                    doc, XPathConstants.STRING);
    String fitnum = fitinfo.replaceAll("\\D+", "");

    if (fitnum != null && recnum.length() == 0) {

        fitint = 470;
        gfit = 0;
    } else {
        fitint = Integer.parseInt(fitnum);
        gfit = fitint;
    }



    List<Integer> list = new ArrayList<Integer>();
    list.add(recnumint);
    list.add(whitenumint);
    list.add(imint);
    list.add(fitint);

    return list;
}

}

As was stated, the problem occurs when the first ‘else’ statement is thrown. If the first case is ‘if’ and the second ‘else’ the third and fourth will be ‘else’ too

  • 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-06-17T12:39:33+00:00Added an answer on June 17, 2026 at 12:39 pm

    All your ifs share the same second condition, perhaps that is the reason?

    Do you mean

    if (imnum != null && imnum .length() == 0) {
                         ^^^^^^
    

    instead of

    if (imnum != null && recnum.length() == 0) {
    

    And similarly

    if (whitenum != null && whitenum.length() == 0) {
                            ^^^^^^^^^
    

    and of course..

    if (fitnum != null && fitnum.length() == 0) {
                          ^^^^^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am maintaining several Perl scripts that all have similar code blocks for different
I have created several if else statements, along with parsing a double and then
I have several Code Analysis CA1704:IdentifiersShouldBeSpelledCorrectly warnings that I want to suppress. Basically, they
I have code in Java that has an outer loop and several nested loops.
I have a weird question. After profiling my code several times with NYTProf. I
I have several HTML code combinations like this: <h2></h2> <p></p> <iframe></iframe> <hr/> and from
I have some code to create a basic dialog box with several options -
I have next code: int main() { OwnSelect(23, FD_READ | FD_WRITE); // <---- Several
I've worked out most of the code and have several game classes. The one
I have a piece of code that takes several rows from a database and

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.