简体   繁体   中英

specify range in XML element

For xml elements, is there a way to specify a range of values for an element? for example, if this is part of my xml my xml:

<store>
     <price1>1-2</price1> **
     <price2>2.34</price2>
</store>

**Is there a way to do this or would I have to do something like this:

<store>
    <price1>1</prince1>
    <price1>2</prince1>
    <price2>2.34</prince2>
</store>

Thank you

XML provides little more than elements, attributes and text. It is up to the software consuming the XML to determine the meaning of them.

So XML provides no barriers to writing 1-2 in a text node, but it is up to the software that reads it to determine that 1-2 represents a range.

A more XMLy approach might be to say:

<price1>
    <from>1</from>
    <to>2</to>
</price1>

… but again, the software consuming it would have to understand the from and to elements.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM