I am using Dom parser for xml parsing and it works fine in android 4. But it can not parse '&' in android 2. For example..if string "Android & iPhone" then it takes only "Android". Any help would be greatly appriciated. Thanks.
Asked
Active
Viewed 418 times
2 Answers
1
That's because the ampersand is a special character in XML. Try using &
instead.
EDIT:
To escape all the specail characters, you could use StringEscapeUtils.escapeXml(String str)
from the Apache commons library, as described in this thread.
You can download the Apache commons library here.
-
I know but the string comes from api.. How can I replace ? – Ketan Ahir Jan 17 '13 at 12:47
-
which file I have to download ? – Ketan Ahir Jan 17 '13 at 13:13
-
when I use... import static org.apache.commons.lang.StringEscapeUtils.escapeHtml; it gives me error. – Ketan Ahir Jan 17 '13 at 13:49
-
Did you manage to resolve the issue? Please accept the answer if so. – Zoltán Jan 18 '13 at 13:33
0
You can also treat it as XPL and process it directly to XML. XPL (eXtensible Process Language) is just like XML, but it allows the XML "special characters" in text elements. link to eXtensible Process Language

Roger F. Gay
- 1,830
- 2
- 20
- 25