SAXParser getting stuck on certain characters

by 3D » Mon, 26 Jan 2009 15:18:22 GMT

Sponsored Links
 I'm using a SAXParser to parse an XML document and its getting stuck
on certain symbols like the 'trademark' symbol and I think even double-
quotes ".  I really don't need these characters so it would be fine if
the parser just skips over these.  Instead it throws an exception and
quits parsing the document.  What can I do?

SAXParser getting stuck on certain characters

by 3D » Wed, 28 Jan 2009 04:10:43 GMT

 Help please.


Sponsored Links

SAXParser getting stuck on certain characters

by 3D » Fri, 30 Jan 2009 04:59:18 GMT

 Thank you both for your responses!  I think I will try just removing
these characters.


SAXParser getting stuck on certain characters

by Brad Gies » Fri, 30 Jan 2009 12:01:14 GMT

 ust in case you want to escape/unescape them (it's a little better), here
is what I use (they are C#, but easy to convert to Java). They are simple. I
found the original on the web, but don't remember the author to give the
credit to :

public String EscapeXML(String str)
StringBuilder sb = new StringBuilder();
foreach (Char c in str)
switch (c)
case '&':
case '<':
case '>':
case '\'':
case '"':
return sb.ToString();

This one could be made faster, but it's simple :).

public String Unescape(String str)
str = str.Replace("&amp;", "&");
str = str.Replace("&lt;", "<");
str = str.Replace("&gt;", ">");
str = str.Replace("&#039;", "\\");
str = str.Replace("&#39;", "'");
str = str.Replace("&quot;", "\"");
str = str.Replace("&lt;", "<");
return str;


Brad Gies

Brad Gies
27415 Greenfield Rd, # 2,
Southfield, MI, USA

Moderation in everything, including abstinence

-----Original Message-----
[] On Behalf Of 3D
Sent: Thursday, January 29, 2009 3:59 PM
To: Android Developers
Subject: [android-developers] Re: SAXParser getting stuck on certain

Thank you both for your responses! I think I will try just removing
these characters.

On Jan 28, 9:14am, "Brad Gies" <> wrote:


SAXParser getting stuck on certain characters

by Scott G » Sat, 07 Mar 2009 10:54:23 GMT


What I found out was that when the parser hit one of those characters
between element tags, the characters function would be called again.
so a value like

<tag>the "dog" runs</tag>
would render 5 calls:

my solution was to intialize a temporary string on the startelement
call, append that string in the characters call, then assign it to the
proper variable end the end element call.


Other Threads

1. non-map/video overlay?

I would like to use views as overlays on other views, and to specify
the layout using xml. I've tried FrameLayouts, AbsoluteLayouts, and
RelativeLayouts, but I can't seem to get 2 views to overlap.

Actually, using the hierarchy viewer, I was able to see that I had a
FrameLayout behind a view, but when I tried to bring the FrameLayout
to the front it was pushed to beside that view.

I tried a couple of attempts using SurfaceView, but I still have the
same issue of setting up the overlapping layout first. I did not get a
SurfaceView to work yet, and I'd really like to stick with non-
SurfaceViews if possible.

The examples I've found for overlays and surface views all seem to be
for maps and video, but I want to overlay my own custom views.

So, how can you set up normal views to overlap?


2. Shipping price to Singapore

Hi all.

I was looking around everywhere on the shipping price of the Android
Dev Phone 1 to Singapore. I know that the device cost $399 USD but
thats excluding the shipping cost and shipping cost differ from
country to country.

Would any one happen to be able to check for the shipping price of the
phone to Singapore since I do not want to waste the dev fee of $25
just to move on to find that shipping price would be too expensive and
I change my mind.

Help on the price would be greatly appreciated.




3. restricting EditText to certain number of characters

4. How to place a call from an application

5. Transparent textures in OpenGL

6. Who know the WMA and WMV playback ?

7. Stack overflow - 32 deep class hierarchy