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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:07:10+00:00 2026-05-21T20:07:10+00:00

I have a PHP webservice that returns an XML output, and one of the

  • 0

I have a PHP webservice that returns an XML output, and one of the Tag contains a multiline “\n” String data.

My problem is, all “\n” is being removed after I pass the XML data through the default SAX parser, but I really dont want this to happen! I want to retain all newline “\n” characters
within the Tag so that I can extract it and display them in a simple TextView or EditText.

I tried a couple of workarounds like substituting the “\n” with “&x#dA;” or something, but I cant get it to work properly with my PHP server, and I feel its not an elegant solution.

Does anyone have a working example or tutorial you can point me to learn how to resolve this? I read in another post here that this is the “lmitation” of the implementation of thsi default SAX parser, but I dont mind using a third part parser if thats gonna solve it, but I will need some guidance…

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-05-21T20:07:11+00:00Added an answer on May 21, 2026 at 8:07 pm

    I had the same problem as you. I found this solution to a similar problem and adapted it to this one.

    StringBuffer sb = new StringBuffer(str.length());
    
    CharacterIterator it = new StringCharacterIterator(str);
    for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) {
        switch (ch) {
            case '\\':
                char next = str.charAt(it.getIndex() + 1);
                if (next == 'n') {
                    // we've found a newline character
                    sb.append('\n');
                } else {
                    sb.append(ch);
                }
                break;
            case 'n':
                char prev = str.charAt(it.getIndex() - 1);
                if (prev == '\\') {
                    // don't append the 'n', we did that above
                } else {
                    sb.append(ch);
                }
                break;
            default:
                sb.append(ch);
                break;
        }
    }
    
    str = sb.toString();
    

    Where str is your string with \n characters. There is probably a more elegant solution to this problem, but I am quite new to java and Android and couldn’t find one.

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

Sidebar

Related Questions

I have a PHP Webservice that returns a JSON string with this format: [{latitud:37.995914,longitud:-1.139705,nombre:Miguel
I have a RPC encoded PHP webservice that returns a simple soap envelope with
I have a working PHP web service that returns data (if I input the
I have created a function in PHP that calls a webservice and parses through
I have to consume a WCF WebServices but the WSDL contains bindings that PHP
I have a PHP script that syncs data with a third party service, and
I have a page on a remote server that returns a single xml value
I have a custom module that returns data from a web service call. It
I have a web service written in PHP, that returns JSON results. It works
Im currently posting some data to a php webservice using a class that extends

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.