xml数据看起来像
<bd>
<oied>
<oeuo>XYZWC999</oeuo>
<oedo>SorNbteluk=ONRM_ROOT_MO_R,SrobeNhbwk=XYZWC999,MoetxeoCt=XYZWC999</oedo>
<oesw>CXP9021776/2_R2CA15</oesw>
</oied>
<bi>
<bts>20150205141500Z</bts>
<gp>900</gp>
<bt>paaoCukStSteboshRrttcps</bt>
<bt>pptubthCaStctoSekSos</bt>
<bv>
<biod>MaebdlgeaooeEt=1,TparswotterNorok=1,Ntcp=Kub-9</biod>
<r>4578</r>
<r>10769</r>
</bv>
<bv>
<biod>MEegoedbaaloet=1,TreatoorNtosrpwk=1,Ntcp=1</biod>
<r>11021</r>
<r>86235</r>
</bv>
<bv>
<biod>MdaolaeeobeEgt=1,TretrowooNrtsapk=1,Nctp=Kub-7</biod>
<r>0</r>
<r>0</r>
</bv>
</bi>
</bd>
我是Scala的新手,我可以找出基本结构。
case class xmldata(oeuo : String, oedo : String, oesw: String, bts: String, gp : Int, btArray : List[String])
此xml数据的优化Scala案例类(带有集合)是什么?
答案 0 :(得分:2)
它只是案例类的树:
case class Bd(oied: Oied, bi: Bi)
case class Oied(oeuo: String, oedo: String, oesw: String)
case class Bi(bts: String, gp: String, bt: List[String], bv: List[Bv])
case class Bv(biod: String, r: List[String])
如果订单无关紧要 - 您可以使用Set
代替List
你也可能会稍微扁平一下(比如你的解决方案),但是用xml绑定工具映射它可能会更难
case class Bd(oeuo: String, oedo: String, oesw: String, bts: String, gp: String, bt: List[String], bv: List[Bv])
最扁平,最不易操作的版本(不推荐):
case class Bd(oeuo: String, oedo: String, oesw: String, bts: String, gp: String, bt: List[String], biods: List[String], rs: List[List[String]])