Xml parsing with dom4j in java
Hi everyone,
i have to debug this part of a program that doesn't wanna work
fo is a variable Concept that has inherited the metods elements()
element() from AbstractElement of dom4j
fo has this structure
fo is written in owl that is very similar to xml
<and xmlns=" http://dl.kr.org/dig/2003/02/lang">
<catom name="Nautical_equipments"/>
<all>
<ratom name="has_anchor_windlass"/>
<and>
< catom name="Anchor_windlass"/>
<catom name="Electric_Anchor_windlass"/>
</and>
</all>
<all>
<ratom name="has_Gangway"/>
<and>
<catom name="Gangway"/>
<catom name="Automatic_gangway"/>
</and>
</all>
</and>
This is the part of the program where i think the problem is...
1. for (int f=0; f<indfirst.size(); f++){
2. Concept fo = (Concept)indfirst.elementAt(f);
3. System.out.println(f + " first for");
4. System.out.println("Concept fo"+ "number " +f+
fo.toString());
5. for(Iterator
h=fo.elements("catom").iterator();h.hasNext();)
6. {
7.
8. System.out.println("List of elements in fo" +
fo.elements().size());
9. System.out.println(h.toString()+ "second for");
10. System.out.println("List of catom elements " +
fo.elements("catom").size());
11. Catom r =(Catom)h.next();
12. System.out.println("Catom" + r.toString());
13. }
Checking the value of the variables with System.out.println at lines 8
and 10, i get that fo.elements("catom").size() is a List of only one
element...that is catom name="Nautical_equipments"/...(line 12)
What is the problem with elements("catom")?
Why doesn't it return a list with all the 5 catom elements i have in
my Xml/Owl???
Is the java code the problem? or the structure of the xml???
Help please!!
Danilo