Reputation: 185
I'm creating a RSS app on Android based in this tutorial http://www.hermosaprogramacion.com/2015/05/tutorial-para-crear-un-lector-rss-en-android/
I deleted some tags that I didn't want to parse and everything runs OK with the original URL, the forbes RSS "http://www.forbes.com/most-popular/feed". Once I change the forbes RSS url for this one I want to use "http://aplicaciones.esi.us.es/antalumnos/rss.xml" I get this error:
06-20 13:51:44.961 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: org.simpleframework.xml.core.ValueRequiredException: Empty value for @org.simpleframework.xml.Element(data=false, name=description, required=true, type=void) on field 'descripcion' private java.lang.String com.herprogramacin.hermosaprogramacion.RssParse.Item.descripcion in class com.herprogramacin.hermosaprogramacion.RssParse.Item at line 11
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Composite.readInstance(Composite.java:580)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Composite.readElement(Composite.java:532)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Composite.readElements(Composite.java:445)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Composite.access$400(Composite.java:59)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Composite.read(Composite.java:201)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Composite.read(Composite.java:148)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
06-20 13:51:44.971 11441-11494/com.herprogramacin.hermosaprogramacion W/System.err: at org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:190)
The first line says "empty value for description" but I don't understand why.This is my code for Item Class, there are 2 files more por RSS and Channel:
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.Root;
/**
* Clase que representa la etiqueta <item> del feed
*/
@Root(name = "item", strict = false)
public class Item {
@Element(name="title")
private String title;
@Element(name="description", required=false)
private String descripcion;
@Element(name="link")
private String link;
public Item() {
}
public Item(String title, String descripcion, String link) {
this.title = title;
this.descripcion = descripcion;
this.link = link;
;
}
public String getTitle() {
return title;
}
public String getDescripcion() {
return descripcion;
}
public String getLink() {
return link;
}
}
Is there any problem with the URL that I want to use?
Upvotes: 0
Views: 1908
Reputation: 3535
Move the description element in a new class.
In order to do that, you need to replace
@Element(name="description", required=false)
private String descripcion;
with
@Element(name="description", required=false)
private Description descripcion;
Then, create a new file Description.java like:
public class Description
{
@Text(required=false)
String descriptionText;
public String getText()
{
return descriptionText;
}
}
In this case, whenever description tag is empty, it will be skipped during deserialization, and your descripcion
field will be simply null.
Upvotes: 1
Reputation: 1067
This looks correct, but the problem may lie with the Channel class. channel too has a description. The error shown in your question mentions description is required (in the Item class it is optional. May be you Channel class is missing: @Element(name="description", required=false)?
Upvotes: 0