0

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.

Sam Hosseini
  • 813
  • 2
  • 9
  • 17
Ketan Ahir
  • 6,678
  • 1
  • 23
  • 45

2 Answers2

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.

Community
  • 1
  • 1
Zoltán
  • 21,321
  • 14
  • 93
  • 134
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