我正在尝试使用 XStream 导入大型 XML 文件(~ 1 GB)。我想使用 anObjectInputStream
来读取它们的流,但我需要跳过第一个元素,然后向下移动几个元素(见下文,我需要导入bag_LVC:Woonplaats
元素)。
我希望有某种方法可以为我感兴趣的元素提供 xstream aReader
或 a 。InputStream
我尝试创建自己的HierarchicalStreamReader
并将其移动到正确的元素,但您只能上下移动:
HierarchicalStreamReader xpp = new XppDriver().createReader(xmlFile);
xpp.moveDown(); // moves to <xb:antwoord>
xpp.move(); // **would move to <xb:producten>, but it private**
xpp.moveDown(); // moves to <xb:producten>
xpp.moveDown(); // moves to <product_LVC:LVC-product>
st = xstream.createObjectInputStream(xpp);
BagWoonplaats bw = (BagWoonplaats) st.readObject();
xstream 或任何 XPP 驱动程序是否有任何方法让您寻找我感兴趣的元素?
xml
<xb:BAG-Extract-Deelbestand-LVC>
<xb:antwoord>
<xb:vraag>
<!-- more elements here -->
</xb:vraag>
<xb:producten>
<product_LVC:LVC-product>
<bag_LVC:Woonplaats>
<!-- elements used as fields -->
</bag_LVC:Woonplaats>
<bag_LVC:Woonplaats>
<!-- elements used as fields -->
</bag_LVC:Woonplaats>
<!-- and so on -->