<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4134.600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face="Courier New" size=2>Hi,</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>I have the following xml
file...</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New"
size=2>***************************************************</FONT></DIV>
<DIV><FONT face="Courier New" size=2><?xml version="1.0"?></FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2><computer><BR>
<type>Personal Computer</type><BR>
<subtype>Dell</subtype><BR>
<subtype>Acer</subtype><BR>
<subtype>Samsung</subtype></FONT></DIV>
<DIV><FONT face="Courier New" size=2>
<type>MiniComputer</type><BR>
<subtype>MC1</subtype><BR>
<subtype>MC2</subtype><BR>
<subtype>MC3</subtype></FONT></DIV>
<DIV><FONT face="Courier New" size=2></computer></FONT></DIV>
<DIV><FONT face="Courier New"
size=2>***************************************************</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>I use the following code...to parse the
data out</FONT></DIV>
<DIV><FONT face="Courier New" size=2>from this xml but not really getting the
correct</FONT></DIV>
<DIV><FONT face="Courier New" size=2>result.</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New"
size=2>***************************************************</FONT></DIV>
<DIV><FONT face="Courier New" size=2>// Build the JDOM Document<BR>Document
JDOMDoc = saxbuilder.build(new File(filename));</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>// Get the root element<BR>Element root =
JDOMDoc.getRootElement();</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>/* Print computer type
information*/<BR>List types = root.getChildren("type");<BR>out.println("Types of
computer has " + types.size() + ".");<BR>Iterator i = types.iterator();<BR>while
(i.hasNext()) {<BR> Element type = (Element)
i.next();<BR> out.println( " * <" +
type.getText() + ">" );<BR></FONT><FONT face="Courier New"
size=2></FONT></DIV>
<DIV><FONT face="Courier New" size=2> /* Print computer subtype
information*/<BR> List subtypes =
type.getChildren("subtype");<BR> out.println("\t--Subtypes of
this " + type.getText() +</FONT></DIV>
<DIV><FONT face="Courier New"
size=2>
" has " + subtypes.size() + ".");<BR> Iterator j =
subtypes.iterator();<BR> while ( j.hasNext() )
{<BR> Element subtype = (Element)
j.next();<BR> out.println( "\t\t" +
subtype.getText() );<BR> }<BR>}</FONT></DIV>
<DIV><FONT face="Courier New"
size=2>***************************************************</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>I got no problem to get "<type>"
element but </FONT></DIV>
<DIV><FONT face="Courier New" size=2>could not get "<subtype>"
data.</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>subtypes.size() return 0 to
me!</FONT></DIV>
<DIV><FONT face="Courier New" size=2>I don't know why?</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>Anyone can guide me on this matter?
Thanks!!!</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>Kian On, Yong</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV></BODY></HTML>