Android,一个不那么简单的 simplexml 问题

发布于 2024-11-14 09:29:14 字数 605 浏览 7 评论 0原文

我需要使用来自 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜宝宝 2024-11-21 09:29:14

你问“我应该将我的班级命名为复数还是单数”,而你在标题中说你的问题并不那么简单?由于您创建的类的名称与程序的执行无关紧要,所以我认为这是一个非常简单的问题。

话虽这么说,我的意见是,您将类命名为“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.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文