がvtd-xmlであなたのタスクを実行するためのコードですが、それは、XML処理技術で芸術の状態であり、そして多くの、より効率的かつSAXよりも書くことは簡単です。 ...キーは、可能な限り
Processing XML with Java – A Performance Benchmark
import com.ximpleware.*;
public class conditionalSelection {
public static void main(String s[]) throws VTDException{
VTDGen vg = new VTDGen();
if(!vg.parseFile("d:\\xml\\condition.xml", false)) // disable namespace
return;
VTDNav vn = vg.getNav();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("/root/parent[child1>20]"); // the xpath selecting all parents with child1>20
int i=0,j=0;
while((i=ap.evalXPath())!=-1){
// now move the cursor to child2 and child3
if(vn.toElement(VTDNav.FC,"child2")){
j = vn.getText();
if (j!=-1)//make sure the text node exist
System.out.println(" child2's text node is ==>"+ vn.toString(j));
vn.toElement(VTDNav.P);
}
if(vn.toElement(VTDNav.FC,"child3")){
j = vn.getText();
if (j!=-1)//make sure the text node exist
System.out.println(" child3's text node is ==>"+ vn.toString(j));
vn.toElement(VTDNav.P);
}
}
}
0解析するSAXを避けるために、あなたの理由の負荷を与えること
this paperを読む...興味のあるノードのみをフィルタリングするためにXPath式を使用することです
なぜサックスだけですか?それは巨大なXMLのためですか? –
はい、それは巨大なXMLのためのもので、すでに既存のコードですが、私はいくつかの変更をしようとしています。 –
どのように巨大ですか? 100のmbまたは100のgb? –