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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:06:16+00:00 2026-06-12T17:06:16+00:00

i just want to parse two values from a html file . there will

  • 0

i just want to parse two values from a html file .

enter image description here

there will be several list elements in the html file and i want to parse two values

a. 1 ,100, 101
b. Swargate to Shivajinagar Circle route , Mnapa bhavan to.. ,Kothrud depot to…

i have used the below code to parse it, but i am not getting the required values , here i am getting href value only.

please give me any solution for the above problem

   String html =

   "<li/><a href=r361.html>1</a> Swargate to Shivajinagar Circle route"+
  " <li/><a href=r511.html>100</a> Manpa bhavan to Hinjewadi phase 3"+
   "<li/><a href=r572.html>101</a> Kothrud depot to Kondhava Bu";

   Reader reader = new StringReader(html);
   HTMLEditorKit.Parser parser = new ParserDelegator();
   final List<String> links = new ArrayList<String>();

   parser.parse(reader, new HTMLEditorKit.ParserCallback(){
       public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
           if(t == HTML.Tag.A) {
               Object link = a.getAttribute(HTML.Attribute.HREF);
               if(link != null) {
                   links.add(String.valueOf(link));
               }
           }
       }
   }, true);

   reader.close();
   System.out.println(links);

}

UPDATE:

Now i am getting the value of a href using below code (using JSOUP Lib)

AssetManager assetManager = getAssets();
InputStream ims =assetManager.open(“index.html”);
Document doc = Jsoup.parse(ims, “UTF-8”, “btc.com”);
Elements busNum = doc.getElementsByTag(“a”);
pTagString = busNum.html();

Log.i(“hh”,” onPostExecute =”+PTagString);

Now i want to get the Value out side the a href for eg: Swargate to shivajinagar circle route.

anybody know the method or any idea

  • 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-12T17:06:18+00:00Added an answer on June 12, 2026 at 5:06 pm

    You don’t even need to use a parse for this. You could use a regular expression.

    See this Tutorial about regex in Java

    And then you’ll need something like this:

    <a[^>]*>([^<]*)<[^>]*>(.*)
    

    as your regular expression. Then you will have both values you need in no time. It’s much more performant than parsing the html.

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

Sidebar

Related Questions

I want to get the maximum values from two images, while preserving other information.
I want to parse a XML file from a server on internet and save
I just want to parse the following string up until the END token then
Is there an existing LISP parser written in C++? I just want the parser,
Just want to know how to read an attribute of a parent node from
I just want to add some extra text on top of input posted from
I need to extract text from an HTML file using C#. I am trying
I have two quick questions which I just want to get the community's opinions
I need to parse xml files from two sources. Both xml files contain the
I want to display the java list data in the html page. So i

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.