[jdom-interest] (no subject)
S Z
sz_jdom at yahoo.com
Mon Aug 7 14:40:12 PDT 2000
Hi,
I am trying to extract some information from
a XHTML file using JDOM, here is what I did,
public static void listChannels(String systemID,
ArrayList addresses, ArrayList ids, ArrayList urls)
throws JDOMException, NullPointerException {
if (systemID == null) {
throw new NullPointerException("URL must
be
non-null");
}
SAXBuilder builder = new SAXBuilder();
// Load the entire document into memory
// from the network or file system
Document doc = builder.build(systemID);
Element html = doc.getRootElement();
System.out.println("The full name for root is:
"
+html.getName());
List children = html.getChildren();
Iterator i1 = children.iterator();
while(i1.hasNext()){
System.out.println("child is: " +
((Element)i1.next()).getName()+"!");
}
//Element head = html.getChild("head");
Element body = html.getChild("body");
Element div = body.getChild("div");
Element table = div.getChild("table");
List trs = table.getChildren("tr");
Iterator iterator = trs.iterator();
But Here is the result I get:
The full name for root is: html
child is: head!
child is: body!
org.jdom.NoSuchElementException: The element body does
not exist within the specified element.
at org.jdom.Element.getChild(Element.java:679)
at org.jdom.Element.getChild(Element.java:733)
at
Inntopia_AS.listChannels(Inntopia_AS.java:71)
at
Inntopia_AS.listChannels(Inntopia_AS.java:36)
at Inntopia_AS.main(Inntopia_AS.java:121)
It's interesting that the list find the body, but
when I use getChild, it doesn't find it. Is it a bug
in JDOM or I did something wrong? Anyone's help
will be greatly appreciated!
Thanks,
SZ
__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/
More information about the jdom-interest
mailing list