[英]difficulty in using SAX parser for same named parent child nodes
Here is the xml to be parsed. 这是要解析的xml。 I want to use sax parser to parse this xml but it is
我想使用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>
these plan tabs can go upto N-levels Can any one there help me find out how to parse it in SAX parser here is the PlansDTO i created for it. 这些计划选项卡可以达到N级可以任何一个帮助我找到如何在SAX解析器中解析它是我为它创建的PlansDTO。
public class PlansDTO {
String _id;
String _name;
String _child_id;
boolean _hasChild;
Vector _childIds;
Hashtable _plans;
Vector contentDTOs;
}
I am having difficulty in handling this tree through sax parser , can any one there help me ? 我通过sax解析器处理这棵树很困难,有没有人可以帮助我?
SAX is a context-free parser, so, if you need context, you have to do it by yourself : your parser should therefore have a reference to the last "plan" instance that has started. SAX是一个无上下文的解析器,因此,如果您需要上下文,则必须自己执行:因此,您的解析器应该引用已启动的最后一个“计划”实例。
You may also consider using another parser like DOM or JAXB : these parsers will keep the context for you. 您也可以考虑使用另一个解析器,如DOM或JAXB:这些解析器将为您保留上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.