Android,一个不那么简单的 simplexml 问题
我需要使用来自 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);
我应该如何定义我的类?
应该命名为“庄园”还是“庄园”?
抱歉,但我还无法感受到 simplexml...;-(
I need to define my android "Estates" class using simplexml package from an xml like this one:
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);
How should I define my class?
Should it be named "Estates" or "Estate"?
Sorry, but I can't yet get a feeling with simplexml... ;-(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你问“我应该将我的班级命名为复数还是单数”,而你在标题中说你的问题并不那么简单?由于您创建的类的名称与程序的执行无关紧要,所以我认为这是一个非常简单的问题。
话虽这么说,我的意见是,您将类命名为“Estate”,并减少其功能,以不假设多个 id/description 元组,并且为了使用多个元组(例如示例中的 000 和 001) ,您在一个容器中使用多个 Estate 对象(数组、列表等)。
You're asking "should I name my class plural or singular" and you're saying in the title that your question is not so simple? Since the name of a class you create is inconsequential to the execution of your program I'd say it's a very simple question.
That being said, my opinion is that you name the class "Estate" and you reduce its functionality to not assume more than one id/description tuple, and in order to use more than one (such as the 000 and 001 in your example), you use multiple Estate objects in a container (array, List, etc.).