simple-framework

SimpleXML deserialization error in Android

断了今生、忘了曾经 提交于 2020-01-03 12:11:10
问题 I have problem with deserialization java-object. For deserialization I use SimpleXML. @Root public class A { @ElementList private ArrayList<B> b; getters, setters... } public class B{ @Element(name="C", required=false) private C c; getters, setters... } public class C{ private int id; private String name; getters, setters... } I receiving XML, which have next field: <A> <B> <C i:nil="true" /> </B> </A> Dalvink throws next exception: org.simpleframework.xml.core.AttributeException: Attribute

Using “Simple” XML Serialization to load data from res/raw on Android

点点圈 提交于 2020-01-02 15:52:28
问题 I am new to Java and Android development, so please keep this in mind. My goal is to deserialize data from xml files packaged into my application. I'm attempting to do this using Simple 2.4 but I get an "Unhandled Exception type exception" error in the code when using .read or .write My code looks something like this: import java.io.InputStream; import android.app.Activity; import android.os.Bundle; import android.view.View; import org.simpleframework.xml.Serializer; import org

XPath (SimpleXML) selection of child based on value of child's sibling

こ雲淡風輕ζ 提交于 2019-12-31 03:30:25
问题 I'm using SimpleXML (Java) and I'm trying to get a List of objects based on the value of one of the siblings of the list. So, here's my XML: <xml> <metadata> <resources> <resource> <ittype>Service_Links</ittype> <links> <link> <path>http://www.stackoverflow.com</path> <description>Stack Overflow</description> </link> <link> <path>http://www.google.com</path> <description>Google</description> </link> </links> </resource> <resource> <ittype>Article_Links</ittype> <links> ... </links> </resource

Prevent inclusion of empty tag for an empty ElementList in an ElementListUnion

你说的曾经没有我的故事 提交于 2019-12-31 02:00:09
问题 I have the following code in one of my classes: @Text(required=false) @ElementListUnion({ @ElementList(required = false, inline = true, type = com.company.Child.class, entry="values") }) public List<Object> valueUnion; Note that this seems to be the only way to get the framework to work with elements that contain both children and text. This works great when text is present and the elementlist contains elements as well, and produces the following xml: <parent> <values>val 1</values> <values

Simple framework skip soap envelope and body

二次信任 提交于 2019-12-30 18:55:08
问题 I'm using RetroFit and Simple XML Framework in Android to model a SOAP response that looks like this: XML: <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <BuslocationResponse xmlns="AT_WEB"> <Version>1.0</Version> <Responsecode>0<

Simple framework skip soap envelope and body

帅比萌擦擦* 提交于 2019-12-30 18:55:07
问题 I'm using RetroFit and Simple XML Framework in Android to model a SOAP response that looks like this: XML: <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <BuslocationResponse xmlns="AT_WEB"> <Version>1.0</Version> <Responsecode>0<

demarshalling an xml where attributes determine type

回眸只為那壹抹淺笑 提交于 2019-12-25 00:34:58
问题 I'm being given xml documents (which I have no control its format). I would like to know if it is possible to demarshal this xml based on element attribute id. So different object types will share the same element name. Also, I'm planning on using Simpile XML because I'm on Android and JAXB doesn't like Android. So I would like something like: class Root { Person p; Car c; ArrayList<Person> plist; } class Person{ String name; } class Car { String type; } from <root> <object id="person"> <name

Deserialize XML elements to different types, based on attribute

天大地大妈咪最大 提交于 2019-12-24 08:48:35
问题 I have an XML document with many Entity elements, which each have an attribute of either type="foo" or type="bar" . See this sample: <RootNode> <Entities> <Entity type="foo"> <Price>1</Price> </Entity> <Entity type="bar"> <URL>www.google.co.uk</URL> </Entity> <Entity type="foo"> <Price>77</Price> </Entity> </Entities> </RootNode> I need a way to tell Simple to deserialize the Entity elements with type="foo" into a List<FooEntity> and the elements with type="bar" into a List<BarEntity> . How

Simple-Framework: Duplicate annotation (different namespace)

可紊 提交于 2019-12-24 05:40:11
问题 I have an Rss feed that I'd like to parse in Java using Simple Framework. I have problems with 2 elements with the same name, but one of them has a namespace assigned. Here is an example xml: <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:dc="http://purl.org/dc/elements/1.1/"> <item> <title>Regular Titel</title> <dc:title>Dc Titel</dc:title> </item> </rss> Currently my Item.class looks like this: @Root public class Item { @Namespace(reference = "http://purl.org/dc/elements/1.1/", prefix =

Simple XML Framework : Having an “inline like” behaviour for objects in ElementMap

那年仲夏 提交于 2019-12-23 19:22:24
问题 i am trying to serialize an Hashmap of custom Objects on Android to get an xml like : <ROWSET> <ROW num="0"> <Name>foo</Name> <FNAME>bar</FNAME> <BIRTH>01/01/2000</BIRTH> <Num>4376484</NUM> </ROW> <ROW num="1"> <Name>bar</Name> <FNAME>foo</FNAME> <BIRTH>02/02/2000</BIRTH> <NUM>4376484</NUM> </ROW> </ROWSET> I created an inner class that contains only the Hashmap that i'm interested in, as i was unable to serialize it the way it is (and read that it's not possible) added an object to test like