Should xml be a collection or a list?

I always think of xml as a set data structure . I.e:

<class>
 <person>john</person>
 <person>sarah</person>
</class>

It is equivalent to:

<class>
 <person>sarah</person>
 <person>john</person>
</class>

Question One: Are these two things logically equivalent?


Are you allowed to do such things in xml?

<methodCall>
  <param>happy</param>
  <param>sad</param>
</methodCall>

Or you need to do it like this:

<methodCall>
  <param arg="1">happy</param>
  <param arg="2">sad</param>
</methodCall>

Question two: Are these two things logically equivalent?


Question three: Is xml usually handled as a collection or list?

+3
source share
3 answers
  • They are logically equivalent if you do not like sort orders.
  • XML. , .
  • XML , .

XML . . , .

+6

XML , , , , . , XML:

<example>
  <foo/>
  <foo/>
</example>

, , /example/foo , /example/foo . , , , , , , XML ( ).

+1

, :

1) XML, . XML, : , . , XML .

2) XML, . . XML - ; . , XML .

3) Elements can be duplicated in XML, and their order is important. However, this document outline may apply the rules of uniqueness and / or ordering. Thus, both sets and lists can be represented. I suppose you could consider raw XML as an ordered default list.

+1
source

Source: https://habr.com/ru/post/1741829/


All Articles