Hi all
 I am getting the value from webservice.my webservice value return
string .mywebservice value is very long .my webservice value are
coming like xml entity referece character <>&  etc .    I
want to replace character < > & .I have to replace these value and
parse these values.i am using dom parser for parsing the value  while
replacing the value I am getting out of memory error .I know we can do
with stream .I don't how to use stream .If any body give example how
to do provide code?
my code is replacing character


public  String unescapeXML(String str) {
            if (str == null || str.length() == 0)
              return "";

            StringBuffer buf = new StringBuffer();
            int len = str.length();
            for (int i = 0; i < len; ++i) {
              char c = str.charAt(i);
              if (c == '&') {
                int pos = str.indexOf(";", i);
                if (pos == -1) { // Really evil
                  buf.append('&');
                } else if (str.charAt(i + 1) == '#') {
                  int val = Integer.parseInt(str.substring(i + 2,
pos), 16);
                  buf.append((char) val);
                  i = pos;
                } else {
                  String substr = str.substring(i, pos + 1);
                  if (substr.equals("&"))
                    buf.append('&');
                  else if (substr.equals("<"))
                    buf.append('<');
                  else if (substr.equals(">"))
                    buf.append('>');
                  else if (substr.equals("""))
                    buf.append('"');
                  else if (substr.equals("'"))
                    buf.append('\'');
                  else if (substr.equals(" "))
                      buf.append(" ");

                  else
                    // ????
                    buf.append(substr);
                  i = pos;
                }
              } else {
                buf.append(c);
              }
            }
            return buf.toString();
          }
Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to