parse big xml file in android
<p>In my application there is an search option .If user type a .I have to get the value from webservice .I am getting large webservice value .In my webservice string value are coming  I am getting like &lt;&gt; like xml character entity reference like  .I want to replace all character and parse xml can anybody tell how to do give example?</p>

<p>I tried with <code>StringBuffer</code> for unescapexml character I am getting out of memory error</p>

<pre><code>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 &lt; len; ++i) {
          char c = str.charAt(i);
          if (c == '&amp;') {
            int pos = str.indexOf(";", i);
            if (pos == -1) { // Really evil
              buf.append('&amp;');
            } 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("&amp;amp;"))
                buf.append('&amp;');
              else if (substr.equals("&amp;lt;"))
                buf.append('&lt;');
              else if (substr.equals("&amp;gt;"))
                buf.append('&gt;');
              else if (substr.equals("&amp;quot;"))
                buf.append('"');
              else if (substr.equals("&amp;apos;"))
                buf.append('\'');
              else if (substr.equals("&amp;nbsp;"))
                  buf.append(" ");

              else
                // ????
                buf.append(substr);
              i = pos;
            }
          } else {
            buf.append(c);
          }
        }
        return buf.toString();
      }
</code></pre>

<p>I tried with stream I am not able to do can anybody give example how to do?</p>
