![](/img/trans.png)
[英]SAX Parser ignoring parent elements? Same named elements grouped as a result
[英]difficulty in using SAX parser for same named parent child nodes
这是要解析的xml。 我想使用sax解析器来解析这个xml,但确实如此
<Plans>
<Plan ID="1" Name="Plan-A">
<Plan ID="4" Name="Plan-A1">
<Content ID="1" Description="Testing plans 123"/>
<Content ID="2" Description="Testing plans 2222"/>
</Plan>
<Plan ID="5" Name="Plan-A2">
<Content ID="3" Description="Testing plans 55551111"/>
</Plan>
</Plan>
</Plans>
这些计划选项卡可以达到N级可以任何一个帮助我找到如何在SAX解析器中解析它是我为它创建的PlansDTO。
public class PlansDTO {
String _id;
String _name;
String _child_id;
boolean _hasChild;
Vector _childIds;
Hashtable _plans;
Vector contentDTOs;
}
我通过sax解析器处理这棵树很困难,有没有人可以帮助我?
SAX是一个无上下文的解析器,因此,如果您需要上下文,则必须自己执行:因此,您的解析器应该引用已启动的最后一个“计划”实例。
您也可以考虑使用另一个解析器,如DOM或JAXB:这些解析器将为您保留上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.