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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:24:39+00:00 2026-06-10T18:24:39+00:00

I am using Java 1.6.0 I am looking for the correct methods of encoding

  • 0

I am using Java 1.6.0

I am looking for the correct methods of encoding special HTML characters in Java

My HTML

 <div id="sliceXML">Florida</div>

I am trying to define a String xmlMatch as the content (in this case Florida) of the above div tag by using the below Java. However i believe i do not have my startTag or endTag defined correctly.

My Java

String testContent = contentPara;
String startTag = "\"sliceXML\">";                      
String endTag = "</div";                                        
String xmlMatch = null; 

int startPosition = testContent.indexOf(startTag);  

if(startPosition >1){

    int subStringIndex = startPosition + startTag.length();                                 
    int endPosition = testContent.indexOf(endTag, subStringIndex);              

    if(endPosition >= startPosition){
        xmlMatch = testContent.substring(subStringIndex, endPosition);
        out.println(xmlMatch.length()); 

    //out.println(startTag);

    out.println("Florida".equals(xmlMatch));
    out.println("florida".equals(xmlMatch));
}   
 }

Any help is much appricated. This would also allow me to answer a previous related question here

EDIT

WORK AROUND SOLUTION

As i explain below, i believe my issue was with the forward slash in String endTag = "</div"; To get past this problem i simply changed my end tag to String endTag = "<";

I still dont know why this happened, it would be great if someone could answer.

  • 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-10T18:24:41+00:00Added an answer on June 10, 2026 at 6:24 pm

    I would really use an HTML parser, such as the confusingly-named JTidy (it’s an HTML pretty-printer, but also gives you a DOM interface to the HTML structure).

    It’ll save you from headaches such as the parsing and handling character entities and encoding.

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

Sidebar

Related Questions

Last day I've spent on looking for correct Java implementation of DSA without using
I am currently looking in to some file uploading using Java Server Faces. I've
I'm looking for a framework or an implementation of Asynchronous Java RMI (preferably using
I'm looking to build a tree-like structure for my Java application. I've tried using
Using java I am trying to develop a method using recursion to analyze a
Using Java (1.6) I want to split an input string that has components of
Using Java IO streams, it is quite often we use objects solely as constructors
Using java If I store windows paths in a h2 database, and then try
(Using Java) I am implementing a generic class which is a B-Tree. When the
Using Java sockets, I made a simple server. This works because it sends data

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.