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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:19:13+00:00 2026-06-14T12:19:13+00:00

I am making a chatting application through smack api. When I send message which

  • 0

I am making a chatting application through smack api. When I send message which include this character ',
the output comes as

message== ma’am

output==

ma

‘

am

here is the code

  StringEscapeUtils.unescapeHtml((new String(ch, start, length).replace("'", "`").replace("'", "'")));

here is the code

DefaultHandler handler = new DefaultHandler() {
                @Override
                public void startDocument() throws SAXException {
                }

                @Override
                public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {                        
                        for (int i = 0; i < attributes.getLength(); i++) {
                            if (attributes.getLocalName(i).equalsIgnoreCase("from")) {
                                from = attributes.getValue(i);
                                break;
                            }
                        }                        
                   ....
                }

                @Override
                public void characters(char ch[], int start, int length) throws SAXException {
                    String str = StringEscapeUtils.unescapeHtml((new String(ch, start, length)));                    
                    switch (elementType) {
                        case 1:
                            msg = str;
                            break;
                     ...
                        default:
                           ...
                            break;
                    }
//                  

                @Override
                public void endElement(String uri, String localName, String qName) throws SAXException {
                }

                @Override
                public void endDocument() throws SAXException {
                }
  • 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-14T12:19:15+00:00Added an answer on June 14, 2026 at 12:19 pm

    Very often, XML parsers will break text elements into multiple character nodes. This is perfectly valid from an XML point of view. So you will need to handle this appropriately.
    So maybe the problem arises from printing, not the unescaping.

    E.g. I can imagine the following XML

    <n>A &amp; B</n>
    

    producing the following events:

    1. begin node n
    2. text node “A“
    3. text node “&amp;“
    4. text node “B“
    5. end node n

    Now if you println every character “thing” you see, you’ll get three lines instead of one. Maybe your parser has an option to enforce “normalizing” the events to join succssive text nodes.

    (Sorry if I’m not using all the appropriate XML teminiology. My XML terminilogy has become a bit rusty, so feel free to edit this question and put in the correct XML terms. Thank you)

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

Sidebar

Related Questions

I am new to the use of smack library and making one chatting application.
Making my PHP Command line application support Linux and Windows. Currently it has this
Making a server in java, First off, Here's the code. AnsiConsole.out.println(This is a Test.);
I'm currently building an application that is about VOIP / random chatting, which is
Ok. I am making a random chatting website here, and the website needs to
Making project through command line behaves as expected and provides neat and colored output:
Making project through command line behaves as expected and provides neat and colored output:
I'm making chatting application for my school's assignment. In my opinion, the default EditText
Making a simple application, so when the user logs out of Windows, it of
Making an adobe flex ui in which data that is calculated must use proprietary

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.