假设我要存储许多元素,例如:
fruitList = "apple", "orange", "banana", "kiwi", ...
您将如何以XML存储这些内容?
<FruitList>"apple", "orange", "banana", "kiwi"</FruitList>
要么
<Fruits Type="Expensive" List="apple", "orange", "banana", "kiwi"> </Fruits>
有没有更好的办法?
无论选择哪种方法,如何将列表轻松解析,以使如果将项目的格式更改为类似以下内容,则无需更改解析:
<FruitList>
"apple",
"orange",
"banana",
"kiwi"
</FruitList>
最佳答案
<Fruits>
<Fruit>Apple</Fruit>
<Fruit>Orange</Fruit>
</Fruits>