convertir xml a json android

Estoy usando java-json.jar para convertir el xml entrante en json factible. El único problema ahora que estoy teniendo es que cuando el xml contiene <![CDATA[ <p>some html</p> ]]> se bloquea con el siguiente registro:

 03-26 16:54:56.176 30119-30119/nl.avrotros.opgelicht E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: nl.avrotros.opgelicht, PID: 30119 java.lang.NoSuchMethodError: No virtual method end()Z in class Lorg/json/XMLTokener; or its super classes (declaration of 'org.json.XMLTokener' appears in /data/app/nl.avrotros.opgelicht-1/base.apk) at org.json.XMLTokener.nextCDATA(XMLTokener.java:69) at org.json.XML.parse(XML.java:165) at org.json.XML.parse(XML.java:272) at org.json.XML.parse(XML.java:272) at org.json.XML.parse(XML.java:272) at org.json.XML.parse(XML.java:272) at org.json.XML.parse(XML.java:272) at org.json.XML.toJSONObject(XML.java:369) at nl.avrotros.opgelicht.api.Opgelicht.testxmltojson(Opgelicht.java:84) at nl.avrotros.opgelicht.api.Opgelicht.<init>(Opgelicht.java:78) at nl.avrotros.opgelicht.api.Opgelicht.getInstance(Opgelicht.java:395) at nl.avrotros.opgelicht.activity.MainActivity.onCreate(MainActivity.java:38) at android.app.Activity.performCreate(Activity.java:5953) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388) at android.app.ActivityThread.access$800(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5312) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696) 

cuando quito las características del CDATA todo va muy bien y bien.

el xml que estoy tratando de analizar:

 <?xml version="1.0" encoding="UTF-8"?> <resources> <hits>17</hits> <max-score>14.431101</max-score> <rows>1</rows> <start>0</start> <facets> <category> <facet value="malware" count="4" /> <facet value="offline webshops" count="4" /> <facet value="opgeletopinternet.nl" count="1" /> <facet value="overig" count="1" /> <facet value="spookfacturen" count="1" /> <facet value="valse e-mails" count="5" /> <facet value="webshops" count="2" /> </category> <facet01 /> </facets> <item id="1" score="14.431101"> <created>1</created> <properties> <property> <key>title</key> <value>'Pas op voor studionstore.com!'</value> </property> <property> <key>teasertitle</key> <value>'Pas op voor studionstore.com!'</value> </property> <property> <key>teasertext</key> <value>Opgeletopinternet.nl waarschuwt voor de malafide webwinkel studionstore·com.</value> </property> <property> <key>intro</key> <value>Opgeletopinternet.nl waarschuwt voor de malafide webwinkel studionstore·com.</value> </property> <property> <key>onlinedate</key> <value>2015-03-26T12:56:54.000000Z</value> </property> <property> <key>episodeonair</key> <value>2015-03-26T12:51:00.000000Z</value> </property> <property> <key>text</key> <value><![CDATA[<p>De malafide webwinkel misbruikt de gegevens van een bonafide bedrijf. Bovendien adverteren ze met te goedkope prijzen. ook hier geldt: wat te mooi lijkt om waar te zijn, is vaak niet waar.<br /><br />Zie hieronder de site.<br /><br /></p>]]></value> </property> <property> <key>status</key> <value>online</value> </property> <property> <key>category</key> <value>Webshops</value> </property> <property> <key>programtitle</key> <value>1</value> </property> <property> <key>programid</key> <value>1</value> </property> <property> <key>owner</key> <value>1</value> </property> <property> <key>source</key> <value>typo3</value> </property> <property> <key>collection</key> <value>alerts</value> </property> <property> <key>portal</key> <value>1</value> </property> <property> <key>type</key> <value>article</value> </property> <property> <key>contenttype</key> <value>article</value> </property> <property> <key>origintype</key> <value>xml</value> </property> <property> <key>resized</key> <value>true</value> </property> <property> <key>converted</key> <value>true</value> </property> <property> <key>image</key> <value> <image default="true"> <imageUrl>http://staticextern.avrotros.nl/images/cc4/OP_tx_news_studionstore.jpg</imageUrl> </image> </value> </property> </properties> <updated>2015-03-26T13:09:28.650Z</updated> </item> </resources> 

¿Alguien sabe cuál es el problema?

Estoy utilizando lo siguiente para analizar realmente el xml:

return XML.toJSONObject(xmlString).toString() ;

Sé que es tarde, pero sólo quería hacer que funcionara así que aquí vas. Tenga en cuenta, esto es sólo una solución rápida y no la mejor práctica.

  1. Descargue todos los archivos del Github-Repo: https://github.com/stleary/JSON-java
  2. Abra XMLTokener.java y comente la línea 69, 70, 71.
  3. Ya terminaste. Tenga en cuenta, si el CDATA no está cerrado, no se producirá ningún error, por lo que este no es el mejor camino a seguir, pero al menos funciona.
  • Diferentes tipos de análisis
  • ¿Cómo recuperar partes del contenido de Wikipedia en la aplicación para Android?
  • ¿Cómo puedo obtener un Android TableLayout para llenar la pantalla?
  • Android: Utilizar matriz de color en XML
  • Crear una vista circular en android
  • Análisis de un XML HttpResponse
  • Error en styles.xml en android-support-v7-mediarouter
  • WYSIWYG View Editor en 'Android'?
  • Android Databinding atributo xml duplicado
  • Android: ¿es posible agregar un enlace que se puede hacer clic en un recurso de cadena
  • Imagen de Android rotación a través de archivo xml
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.