XML中的数组定义? [英] Array definition in XML?

查看:1395
本文介绍了XML中的数组定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XML中,如何声明整数数组?

In XML, how do I declare array of integers?

我可以声明如下:

<numbers type="array">
    <value>3</value>
    <value>2</value>
    <value>1</value>
</numbers>

但是也许有这样一种更简单的方法吗?

but may be there's simpler way like this?

<numbers [3,2,1]></numbers>

推荐答案

第二种方法不是有效的XML.你是说<numbers>[3,2,1]</numbers>吗?

The second way isn't valid XML; did you mean <numbers>[3,2,1]</numbers>?

如果是这样,则首选第一个,因为获取数组元素所需的只是一些XML操作.在第二个上,您首先需要获取< numbers>的值.元素通过XML操作,然后以其他方式解析[3,2,1]文本.

If so, then the first one is preferred because all you need to get the array elements is some XML manipulation. On the second one you first need to get the value of the <numbers> element via XML manipulation, then somehow parse the [3,2,1] text using something else.

或者,如果您确实想要某种紧凑格式,则可以考虑使用JSON(本地"支持数组).但这取决于您的应用程序要求.

Or if you really want some compact format, you can consider using JSON (which "natively" supports arrays). But that depends on your application requirements.

这篇关于XML中的数组定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆