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 '&':
sb.Append("&");
break;
case '<':
sb.Append("&lt;");
break;
case '>':
sb.Append("&gt;");
break;
case '\'':
sb.Append("&#039;");
break;
case '"':
sb.Append("&quot;");
break;
default:
sb.Append(c);
break;
}
}
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;
}



Sincerely,

Brad Gies


-----------------------------------------------------------------
Brad Gies
27415 Greenfield Rd, # 2,
Southfield, MI, USA
48076
www.bgies.com www.truckerphone.com
www.EDI-Easy.com www.pricebunny.com
-----------------------------------------------------------------

Moderation in everything, including abstinence

-----Original Message-----
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of 3D
Sent: Thursday, January 29, 2009 3:59 PM
To: Android Developers
Subject: [android-developers] Re: SAXParser getting stuck on certain
characters


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

On Jan 28, 9:14am, "Brad Gies" <rbg...@gmail.com> wrote:
them,
you
the


--~--~---------~--~----~------------~-------~--~----~



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:
the
"
dog
"
runs

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. Getting and saving bookmarks

Hi,

Can someone tell me how to get access to bookmarks and also add
bookmarks?

Thanks alot

chris

-- 

2. Attention developers: Orange is looking for great Apps !

Orange is looking forward to talking to you at LeWeb (Paris, 9th and
10th of December) - showing you the new on-device App Shop client, and
hearing all about your apps. If you're in Paris next week, come and
see us.

Can't attend LeWeb? Come and talk to us now on the new Orange App Shop
Developer Community Platform...
http://appshopcommunity.orangepartner.com

All the questions you've always want to ask Orange are just a few
clicks away. Join us and also talk to a 100 other developers in the
platform.

See you online !

Camille Bosquet
(Orange Developer Platform Community Manager)

-- 

3. unavailable shared library

4. add item to hyperlink context menu

5. How to change developer account associated with app

6. How to zoom control in Android?

7. html5 and video tag working example