开发者

Xml definition containing multiple instances of a type?

I want to create an xml document that has multiple instance of a type, not sure what's the proper way to do this:

<farm>
  <hors开发者_开发知识库es>
    <horse name="jo"></horse>
    <horse name="bill"></horse>
  </horses>
</farm>

or should I skip the tag and just do this:

<farm>
  <horse name="jo"></horse>
  <horse name="bill"></horse>
</farm>

which way is correct?

Thanks


It's xml, you're free to choose whatever you like best :)

Seriously - both are ok; but think about who you want to please.

As a programmer that would need to consume XML, I would like the first form better. As an editor that would need to manually create XML I would like the second form better.

I guess i would probably settle for the first form.


I fail to see how way 1 is better than way 2.

Since there is a separate type (that is, separate node name) for horses, an additional wrapper, horses, does not make much sense to me. It would, it horses needed to be separated into several groups, say, horsesToKeep and horsesToSell.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜