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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:46:19+00:00 2026-05-31T10:46:19+00:00

I am processing an xml document and reading value from it. One of the

  • 0

I am processing an xml document and reading value from it. One of the value that am reading has / in it. This is how the value looks: M/S John Smith At 4. I was doing some testing on emulator and it was showing the correct value. Now i deployed my app to my Samsung Galaxy S2 device and the process is not reading the value correctly. It just shows M in the value field for that name.

I am thinking it could be because / is a special character. Is there something i can do to escape the special character in the value and read the whole name as it is?

P.S.: I am not an experienced Java Developer so this question may sound stupid to you but if you have the solution, please let me know.

When i am printing the value in console window, this is how it reads in the xmlDocument after parsing it: M/S John Smith At 4

This function reads the value:

public static String getCharacterDataFromElement(Element e) {
        Node child = e.getFirstChild();
        if (child instanceof CharacterData) {
          CharacterData cd = (CharacterData) child;
          return cd.getData();
        }
        return "";
      }

In the adove function, cd.getdata() returns M

After some more debugging:

When i see the element in the watch window, for other names it has only one child. But for the element that contains / it got 3 children. It slices the stringbuffer bcz it sees / in there. I guess either i have to change the below function and ready all the child nodes or i have to use escape character in there before i pass it on.

  • 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-31T10:46:20+00:00Added an answer on May 31, 2026 at 10:46 am

    This is what the new method now looks like:

    public static String getCharacterDataFromElement(Element e) {
        return e.getTextContent();
      }
    

    As of now this is working. I dont know for how long but hopefully till i decide to do the right thing and iterate over child nodes and concatenate the string values.

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

Sidebar

Related Questions

I'm doing some pre-processing of an XML document in a ASMX Webservice (Legacy .NET
This [servlet or jsp] must return an XML document [for future processing by my
I am trying to get a xml document back from the webserver that also
I'm reading a XML file with dom4j. The file looks like this: ... <Field>&#13;&#10;
Essentially I want to embed some XHTML in an XML document that must validate
I'm processing an XML document which has <paragraph> tags which contain text into a
I'm adding nodes to my XML document as part some in-house processing, but cannot
I've been doing alot of XML processing in C# of late and after coming
I've been doing quite a bit of simple XML-processing in python and grown to
First, how do I format the XML processing instruction, is it: <?processingInstructionName attribute=value attribute2=value2?>

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.