xpath - How to represent multiple values for a single node in XML? -


<?xml version="1.0" encoding="utf-8"?>     <code_details>         <summer_redeem_code>54</summer_redeem_code>         <winter_redeem_code>38</winter_redeem_code>     </code_details> 

in above code, think of summer_redeem_code , winter_redeem_code tags want store multiple values. imagine summer_redeem_code passed values such 54,56,57 first 1 i.e. 54 can displayed. also, winter_redeem_code passed values such 38,48,58 first 1 i.e. 38 can displayed.

question: trying figure out best way represent multiple values single element/attribute/tag in xml can display more first 1 can now?

currently these tags 1:1 relationship , want make them 1-many (if makes sense?). basically, looking method(tags) can accommodate values.

constraints:
1) tags summer_redeem_code , winter_redeem_code cannot deleted break parser cannot modified.
possible solution: require leaving them , introducing new 1-many item new tag - maybe "redeem_codes" , putting under it.

the common ways of doing are:

  1. wrapped sequences of elements

    <codes>   <winter>     <wintercode>54</wintercode>     <wintercode>58</wintercode>     <wintercode>92</wintercode>   </winter>   <summer>     <summercode>85</summercode>     <summercode>32</summercode>   </summer> </codes> 

(2) same without wrapper elements

<codes>     <wintercode>54</wintercode>     <wintercode>58</wintercode>     <wintercode>92</wintercode>     <summercode>85</summercode>     <summercode>32</summercode>  </codes> 

(3) list-valued content

 <codes>     <wintercode>54 58 92</wintercode>     <summercode>85 32</summercode> </codes> 

choosing between these involves trade-offs: ease of creating content, ease of validating, ease of reading content, size, compatibility past, extensibility future. can decide what's right you.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -