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. How to register my listener to a particular port

I am using the following function to send Data SMS to my device:


sendDataMessage(String destinationAddress, String scAddress, short
destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent
deliveryIntent)
Send a data based SMS to a specific application port.

I am not able to figure out how do i register my recipient application
to a particular port to receive these data sms messages.

Regards,
Aishwarya

-- 

2. onActivityResult is not triggered

HI,

I have a Activitygroup and some activity are part of it.

lets say Activitygroup is DetailsGroup which has a activity by name
DetailsActivity.

On certail events DetailsActivity launches another activity ExtraActivity by
calling startActivityForResult(intent, 2);

The extraActivity is launched it does whatever it suppose to and before
finish() of it I am calling setResult(RESULT_OK,mintent);

By doing this I was expecting that the DetailsActivity's onActivityResult()
would be called, but instead DetailsGroup activities' onActivityResult() is
getting called.

Any idea what changes are required to get DetailsActivity's
onActivityResult() called in above scenario?

Thanks,
Narenda

-- 

3. Testing desire2nexus

4. Storing DRM protected wallpaper or ringtones

5. Knowing current country

6. 2.1 on ADP1?

7. Memory leak in shared library - any way to find out