我正在尝试使用 XML 存储一些信息,对数据进行分组的正确方法是什么?我在三个房间中有多台计算机,我应该创建房间元素还是使用属性?
<rooms>
<room name="Room 1">
<computer>
<name>Student14</name>
<ipaddress>00.00.00.01</ipaddress>
<macaddress>00-0B-DB-74-12-AB</macaddress>
</computer>
</room>
<room name="Room 2">
<computer>
<name>Student15</name>
<ipaddress>00.00.00.02</ipaddress>
<macaddress>00-0B-DB-74-12-AC</macaddress>
</computer>
</room>
<room name="Room 3">
<computer>
<name>Student16</name>
<ipaddress>00.00.00.03</ipaddress>
<macaddress>00-0B-DB-74-12-AD</macaddress>
</computer>
</room>
</rooms>
或者像这样:
<computers>
<computer>
<name>Student14</name>
<ipaddress>00.00.00.01</ipaddress>
<macaddress>00-0B-DB-74-00-AC</macaddress>
<location>Room 1</location>
</computer>
<computer>
<name>Student15</name>
<ipaddress>00.00.00.02</ipaddress>
<macaddress>00-0B-DB-74-00-AB</macaddress>
<location>Room 2</location>
</computer>
<computer>
<name>Student16</name>
<ipaddress>00.00.00.03</ipaddress>
<macaddress>00-0B-DB-74-00-AD</macaddress>
<location>Room 3</location>
</computer>
</computers>