Is it acceptable to repeat xml elements as shown in this example? Notice in the first example how the 'period_data' element is just repeated directly inside the 'usage_history' element without first being wrapped inside something like a 'periods' parent element.
Initially it seems reduant to me to include the 'periods' parent element as the only thing inside the 'usage_history' parent are 'period_data' elements anyway.
Thank you.
<usage_history num_periods="2">
<period_data billing_year="2013" billing_period="2">
content...
</period_data>
<period_data billing_year="2013" billing_period="1">
content...
</period_data>
</usage_history>
as opposed to this...
<usage_history>
<periods num_periods="2">
<period_data billing_year="2013" billing_period="2">
content...
</period_data>
<period_data billing_year="2013" billing_period="1">
content...
</period_data>
</periods>
</usage_history>
Yes. That is fine. There is no need for an extra enclosing element.
I would also say that num_periods="2"
is wrong, as the period_data
elements should account for themselves.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.