Simple Framework を使用して xml ファイルを解析しています。親ノードを持たないリストを除いて、必要なものはすべて解析できます。「category.xml」の下のコード スニペットは、xml 形式と親のないカテゴリのリストを示しています。Category
class と my Root classのコードも含めましたArrayOfTypeCategory
。解決策は簡単だとおかしな感じがありますが、指でしか触れられません。それは何か関係があり(inline=true)
ますか?どんな助けでも大歓迎です。
---category.xml---
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfCategory xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ACCUMobileWS.org/">
<Category>
<CategoryId>99</CategoryId>
<Name>Frank</Name>
<Description>Prison Break</Description>
</Category>
<Category>
<CategoryId>101</CategoryId>
<Name>Jim</Name>
<Description>Breakig Bad</Description>
</Category>
</ArrayOfCategory>
---カテゴリ クラス---
package com.SimpleFramwork;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Text;
@Element
public class Category {
@Text
public String CategoryId;
@Text
public String Name;
@Text
public String Description;
}
---ArrayOfTypeCategory クラス----
package com.SimpleFramwork;
//imports
import java.util.List;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@Root
public class ArrayOfCategory {
@ElementList(inline = true)
private List<Category> list;
public List getCategories() {
return list;
}
}
プロジェクトを実行すると、log cat にこのエラーが表示されます '
org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=true, name=, required=true, type=void) on field 'list' private java.util.List com.SimpleFramwork.ArrayOfCategory.list for class com.SimpleFramwork.ArrayOfCategory at line 2'