xmarston
xmarston

Reputation: 883

Android Parse ampersand in XML

In an app I'm developing I get an XML string that I have to parse in the app to properly store the data in the local database. The problem is that when a field in the XML has an ampersand like a trademark ("Pans&Company" e.g.), the parser crashes with the next error: ParseException: undefined entity.

How I can handle this situations easily with SAXParser? This is driving me crazy, I read a ton of solutions but any is useful for me.

Upvotes: 0

Views: 272

Answers (1)

Michael Kay
Michael Kay

Reputation: 163587

You can't handle invalid XML with an XML parser - you have to deal with it at source. Find out who is generating this incorrect XML and get them to fix their code. An ampersand must be written as &.

Upvotes: 2

Related Questions