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. listview (text+icon) inside a class Atcivity and not ListActivity

Hi

I want to know if its possible to make a listview (text+icon) on a
class extends Activity and not on a class extends ListActivity.

So I make a little code with class extends.

on the onCreate:

ListView list=(ListView) findViewById(R.id.list1);

ArrayList mStrings = new ArrayList();

ArrayAdapter mAdapter = new ArrayAdapter
(this,android.R.layout.simple_list_item_1, mStrings);

mAdapter.add("itemAdd ");
Log.v(TAG, mAdapter.getItem(0));
mAdapter.add("itemAdd1 ");
mAdapter.add("itemAdd2 ");
mAdapter.add("itemAdd3");
mAdapter.add("itemAdd4");
mAdapter.add("itemAdd5");
mAdapter.add("itemAdd6");
mAdapter.add("itemAdd7");
mAdapter.add("itemAdd8");
mAdapter.add("itemAdd9");

list.setAdapter(mAdapter);

so I find on the ApiDemos android the List14.java class using
EfficientAdapter class.

http://developer.android.com/intl/fr/guide/samples/ApiDemos/src/com/example/android/apis/view/List14.html

My question is, Can I just use class extends Activity to use the same
things like List14.java, with getView(int position, View convertView,
ViewGroup parent) ????

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

2. Will Animated GIF format be supported in Android Browser?

We understand that currently there is no Media Format support for
Animated GIF from the standard Android platform. Is there any roadmap
for that to be supported in Android Browser in the future?

Thanks

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

3. Federated app directories

4. Reasons for working in the platform instead of SDK

5. Samsung i7500 side lock button - why?

6. Reasons for working in the platform instead of SDK

7. How to send andio file to voice channel during call