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

  • SEARCH
  • Home
  • 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 9130679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:00:21+00:00 2026-06-17T08:00:21+00:00

I’m working on a project and have encountered a problem. I am trying to

  • 0

I’m working on a project and have encountered a problem. I am trying to parse html using html cleaner and then use xpath to return a string. I made it return a stacktrace if it found an error (Which it did). I really have no idea how to go about debugging it based on the stack trace. Here’s the code.

package ru.habrahabr.stackparser;

import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.htmlcleaner.TagNode;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class stackParser extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button button = (Button) findViewById(R.id.parse);
    button.setOnClickListener(myListener);
}


private ProgressDialog pd;

private OnClickListener myListener = new OnClickListener() {
    public void onClick(View v) {
        pd = ProgressDialog.show(stackParser.this, "Working...",
                "request to server", true, false);
        new parseSite()
                .execute("http://wiki.teamliquid.net/starcraft2/3_Gate_Robo");
    }
};

private class parseSite extends AsyncTask<String, Void, String> {
    protected String doInBackground(String... arg) {
        String output = new String();
        try {
            htmlHelper hh = new htmlHelper(new URL(arg[0]));
            output = hh.htmlHelper(arg[0]);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return output;
    }


    protected void onPostExecute(String output) {
        pd.dismiss();
        TextView view = (TextView) findViewById(R.id.tv1);
        view.setText(output);

    }
}

Here’s my HTML helper class

package ru.habrahabr.stackparser;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import org.htmlcleaner.XPatherException;

public class htmlHelper {
TagNode rootNode;

public htmlHelper(URL url) {
    // TODO Auto-generated constructor stub
}

public String htmlHelper(String arg) throws IOException, XPatherException
{
    CleanerProperties props = new CleanerProperties();

    // set some properties to non-default values
    props.setTranslateSpecialEntities(true);
    props.setTransResCharsToNCR(true);
    props.setOmitComments(true);

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

    Object[] nodes = rootNode.evaluateXPath("//h1[@id='firstHeading']");

    String things = nodes.toString();

    return things;
}

The UI and loading bar work fine but the TextView keeps returning [Ljava.lang.Object;@42455a88

I’d really appreciate some help with this…i’ve wrestled with it all day and can’t seem to figure it out. Thanks!

  • 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-17T08:00:22+00:00Added an answer on June 17, 2026 at 8:00 am

    I figured it out. The Xpath query was referring to the DOM tree in the XML document. So, in order to avoid a throws, the DOM tree needs to be initialized after cleaning. Then the Xpath will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to understand how to use SyndicationItem to display feed which is
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have been unable to fix a problem with Java Unicode and encoding. The

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.