我需要使用像这样的xml中的simplexml包来定义我的android“Estates”类:
String xml = "
<?xml version="1.0" encoding="utf-8"?>
<estates>
<000>
<id>12345678</id>
<description>estate one</description>
</000>
<001>
<id>23456789</id>
<description>estate two</description>
</001>
</estates>
";
Estates estates = serial.read(Estates.class, xml);
我应该如何定义我的课程?
它应该被命名为“Estates”还是“Estate”?
很抱歉,我还不能对simplexml感到...; - (
答案 0 :(得分:1)
你问“我应该把我的班级命名为复数还是单数”而你在标题中说你的问题并不那么简单?由于你创建的类的名称对于程序的执行是无关紧要的,我会说这是一个非常简单的问题。
话虽如此,我的意见是你将类命名为“Estate”,并且你将其功能降低为不假设多个id / description元组,并且为了使用多个(例如000和001)你的例子),你在容器中使用多个Estate对象(数组,List等)。