simple-framework

ElementListUnion - Simple xml giving duplicate annotation for generic list objects

人走茶凉 提交于 2019-12-13 16:37:39
问题 I am trying to deserialize a List field using elementlistunion Customer.java @ElementListUnion({ @ElementList(inline = false, type = Thing.class), @ElementList(inline = false, type = AnotherThing.class) }) List<Object> things = new ArrayList<Object>(); where Thing and AnotherThing are 2 POJO's.But Iam getting the following exception 03-21 18:56:31.940: E/AndroidRuntime(2289): Caused by: org.simpleframework.xml.core.PersistenceException: Duplicate annotation of name 'things' on @org

Simple Xml Framework loose mapping not working

天大地大妈咪最大 提交于 2019-12-13 00:12:57
问题 I am trying to parse part of an xml document using Simple Xml Framework with the loose mapping flag set but i get an exception. XML: <Body> <TopGoalScorersResponse> <TopGoalScorersResult> <tTopGoalScorer> <sName>Alan Dzagoev</sName> <iGoals>3</iGoals> <sCountry>Y</sCountry> <sFlag>http://footballpool.dataaccess.eu/images/flags/ru.gif</sFlag> <sFlagLarge>http://footballpool.dataaccess.eu/images/flags/ru.png</sFlagLarge> </tTopGoalScorer> </TopGoalScorersResult> </TopGoalScorersResponse> </Body

How to deserialize xml into a map of custom attributes (and their values) with SimpleXml?

ぐ巨炮叔叔 提交于 2019-12-12 17:18:47
问题 I am using SimpleXml. The xml I am deserializing looks roughly like so: <?xml version="1.0" encoding="UTF-8"?> <test a="1" e="2" f="5"/> That the attributes happen to be a , e and f is not known at runtime - could be q and z just as well. The class definition: @Root (strict = false) public class Test { @ElementMap (entry = "test", attribute = true) public HashMap<String, Integer> map; } I expect Test.map to contain "a" -> 1 , "b" -> 2 and "f" -> 5 after deserialization. Instead, I keep on

SimpleXML framework: element with element or text

China☆狼群 提交于 2019-12-12 09:02:46
问题 I must to parse XML which can have two forms: <Command><Variable/></Command> or: <Command>some text</Command> How can I do this? When I try to declare both @Element and @Text in class responsible for Command parsing then exception is thrown when I try to parse XML to instance of this class. My current version of code: @Root(name = "Command", strict = false) public class AppCommand { @Element(name = "Variable", required = false) @Getter private Variable variable; @Text(required = false)

Android Retrofit 2 Simple XML Converter

时光怂恿深爱的人放手 提交于 2019-12-12 07:34:01
问题 I am using Retrofit 2.1.0 and Retrofit SimpleXML Converter 2.1.0 . I added simplexmlconverter to retrofit instance with addConverterFactory method. XML is below <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" version="2.0"> <channel> <title>title</title> <description></description> <language>en-us</language>

PersistenceException -Duplicate annotation of name in Simple XML deserialization

拜拜、爱过 提交于 2019-12-11 22:00:14
问题 I test simple xml tutorial from this link. I change the xml file like this. <example xmlns:ns1="http://www.blah.com/ns/a"> <a> <b> <x>abc</x> <ns1:x>blah</ns1:x> </b> </a> </example> and I add the following coding into the Example7 class. @Path("a/b") @Element(name = "x") private String x_; I got this exception PersistenceException : Duplicate annotation of name 'x' on field 'x' . I would like to know how to overcome this exception. Thanks. 回答1: You need to annotate your field x within your

Parsing French text with simple-Framework not working

六月ゝ 毕业季﹏ 提交于 2019-12-11 15:36:33
问题 I'm using simpleFramework for parsing an xml file in my android app. My problem is in parsing french text like lets say this tag <TagName>écrite</TagName> The result I will receive when parsing is something like this "écrite" This is encoding (french) problem in the simpleFramework xml. How can avoid that and have my text "écrite" the xml header has utf8 : <?xml version="1.0" encoding="UTF-8"?> 回答1: I have hit this issue before whilst using a SAX parser. When reading the file with a Java

SimpleXML: Element 'link' is already used

余生长醉 提交于 2019-12-11 12:33:40
问题 Hello and sorry for my bad English. Look at the XML I'm trying to parse: <author> <name>Name</name> <y:link href="http://api-yaru.yandex.ru/person/20623655/" rel="self"/> <y:link href="http://upics.yandex.net/20623655/normal" rel="userpic"/> </author> And SimpleXML code looks like: public class Author_feed { @Element private String name; @ElementList(inline = true) @Namespace (prefix = "y") private List<Link_feed> link; } Hovewer I see an error: Element 'link' is already used...[and points to

SimpleXML deserializing object serialized elsewhere gives UnparseableDateException

自古美人都是妖i 提交于 2019-12-11 07:55:16
问题 I have a relatively simple class. I serialize it using JDK 1.7 on my server, and deserialize it using Android 2.2 on my client, both of which are using simple xml 2.6.2. The class contains a Date field which I annotate with @Attribute. Resulting XML looks something like this: <daySchedule id="e086b34c-2836-4ecb-af36-5764e3f44b21" date="2012-03-29 00:00:00.0 BST"> <driver id="022cbb89-1226-4d85-ac28-b4848f3bc4ae" name="Julian"/> <job id="1e444bf0-59ec-44f6-8f94-01e8606caa27" scheduledStartTime

Built a class “TimetableData” using simpleframework that saves fine as xml, but when I try reading it in code, it throws PersistenceException

浪尽此生 提交于 2019-12-11 07:36:10
问题 04-21 20:09:17.590: W/System.err(23059): org.simpleframework.xml.core.PersistenceException: Constructor not matched for class com.example.simplexml.DayData my main class where I am saving the data in the xml File which seems to work fine Serializer serializer = new Persister(); TimetableData timetableData = new TimetableData(); SubjectData programming = new SubjectData("Programming","ECG 12",1200, 1400); SubjectData electronics = new SubjectData("Electronics","ECG 13", 1400, 1600);