问题描述
<?xmlversion="1.0"encoding="UTF-8"?><Document><fujiedian><MsgId><Id>0090758109042009123102024984</Id><time>2009-08-26T10:00:24</time></MsgId><SummryDt><Dt>2009-10-29</Dt></SummryDt><Ptcpt><Acct><AcctSvcr>317110010019</AcctSvcr></Acct><ForMsgs><MsgId>0000000099682009102900119284</MsgId><MsgId>0000000099682009102900119294</MsgId><MsgId>3171100100192009102908751134</MsgId><MsgId>3171100107202009102903456250</MsgId><MsgId>0011000015092009102900000046</MsgId><MsgId>0000000099682009102900109955</MsgId><MsgId>0000000099682009102900109956</MsgId><MsgId>0000000099682009102900109957</MsgId><MsgId>0000000099682009102900109965</MsgId><MsgId>0000000099682009102900109966</MsgId><MsgId>0000000099682009102900109983</MsgId></ForMsgs></Ptcpt><Ptcpt><Acct><AcctSvcr>317110010720</AcctSvcr></Acct><ForMsgs><MsgId>3171100107202009102902923400</MsgId><MsgId>4021100119212009102905569272</MsgId><MsgId>3171100100192009102903178755</MsgId></ForMsgs></Ptcpt><Ptcpt></fujiedian></Document>
大家好:我需要把这些XML文件(上面的是简写版)用java读取出来。我用的方法是先判断,判断出父节点下有子节点就创建一个父节点的java对象。父节点下的子节点还有它的子节点的话继续创建java对象。如果子节点有属性创建java对象,没有属性它就是父节点java对象的一个属性。我已经解决好了子节点重复的问题。是用List集合来做的。但是,现在的问题是我没能把<MsgId>3171100107202009102902923400</MsgId>这类的相同子节点读取出来。上面的只是简写版,后面还有很长,3000多行。大神们帮帮忙。感谢!