XML : xml unmarshalling questions

Now, the xml is something like below:

  <db>   <type1>     <data1>...</data1>     <data2>...</data2>            ...     <data7>...</data7>   </type1>   <type2>     <meta1>...</meta1>     <meta2>...</meta2>            ...     <meta9>...</meta9>   </type2>  .....  </db>    

This xml just contains several type1 and type2 information. I hope to unmarshall this xml file and just need the information data1,data3,data5 of type1 and meta1, meta4, meta6 of type2.

For type1, every type1 contains data1, data3 and data5, but may not contains data2,data4,data6, data7.

For type2,every type1 contains meta1, meta4 and meta6, but may not contains meta2,meta3,meta5, meta7,meta8,meta9. I have three questions:

First, How can I deal with two types in this xml file? define two class?

Second, I don't know how to solve the problem that data2,data4,data6, data7 may not appear in this xml file.

Third, Do I need two define two list to save the result? because there are many tags like type1 and type2.

Can anyone give me some link to learn? I find a lot, but they are not helpful. Thanks!!!

No comments:

Post a Comment