簡體   English   中英

難以將SAX解析器用於相同的命名父子節點

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM