[jdom-interest] (no subject)

Brett McLaughlin brett.mclaughlin at lutris.com
Mon Aug 7 15:42:14 PDT 2000


S Z wrote:
> 
> Hi,
>    I am trying to extract some information from
> a XHTML file using JDOM, here is what I did,

Are you using the latest CVS version? Lots of bugs like this have been
fixed since Beta 4.

-Brett

> 
> 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/
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list