简体   繁体   English

使用Digester解析XML

[英]Parsing XML using Digester

I have a xml and it has a list tag with number of items. 我有一个xml,并且具有带有项目数的列表标签。

Example: 例:

    <param>
       <id>12345</id>
       <date>2012/07/10</date>
       <list>
         <item>
           <name>Test1</name>
           <code>C1</code>
         </item>
         <item>
           <name>Test2</name>
           <code>C2</code>
         </item>
       </list>
    </param>   

I want to map this in to Java a object using Jakarta Digester framework. 我想使用Jakarta Digester框架将此映射到Java对象。

My plan is this. 我的计划是这样。

  1. Create a main ResponseDTO 创建一个主ResponseDTO
  2. Create a ItemDTO 创建一个ItemDTO
  3. Add a ItemDTO Array List to ResponseDTO 将ItemDTO数组列表添加到ResponseDTO

So after parsing this xml to Jakarta Digester engine I'm expectibg a ResponseDTO with ItemDTO list which are having real values. 因此,在将这个xml解析到Jakarta Digester引擎之后,我期望具有ItemDTO列表的ResponseDTO具有真实值。

Could some one kindly let me know how I can do this using Digester framework. 有人可以让我知道如何使用Digester框架执行此操作。

Have a look to this article: http://www.devx.com/Java/Article/21832 看看这篇文章: http : //www.devx.com/Java/Article/21832

But there are dozen of XML de/serialization frameworks that are much more user friendly... ( http://x-stream.github.io/tutorial.html#init ). 但是有十二个XML反/序列化框架对用户更加友好...( http://x-stream.github.io/tutorial.html#init )。

M. M.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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