Re: [Simple-support] Read text or elements for the same element tag
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2012-02-15 09:09:52
|
You will have to use a Converter, @Text can not be used with any element annotation.
--- On Tue, 14/2/12, Nugroho Saputro <nug...@gm...> wrote:
From: Nugroho Saputro <nug...@gm...>
Subject: [Simple-support] Read text or elements for the same element tag
To: sim...@li...
Received: Tuesday, 14 February, 2012, 10:24 PM
Hi,
I have the following XML. custom_field element can contains a Text or a set of elements.
<record><custom_field id="2">Value 1
</custom_field><custom_field id="2"> <option selected="true">option 1</option> <option>option 2</option></custom_field>
</record>
I tried the following annotation
@Root(name="record", strict=false)public class Record {
@ElementList(entry="custom_field", inline=true, required=false)
public List<CustomField> customFields = new ArrayList<CustomField>();
}
------------
@Root(name="custom_field", strict=false)public class CustomField {
@Text(required=false)
public String value; // single value
@ElementList(inline=true, entry="option", required=false)
public List<FieldOption> options = new ArrayList<FieldOption>(); // options value
}I get this error :
Unable to read XML. Text annotation @org.simpleframework.xml.Text(data=false, empty=, required=false) on field 'value' public java.lang.String com.test.CustomField.value used with elements in class com.test.CustomField
Any idea to solve this problem?I wonder if I can use converter but where should I put it as I don't use @Element here.Thank you.Reagrds,
Nugroho
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|