[jdom-commits] I have a problem with JDOM

S Z sz_jdom at yahoo.com
Mon Aug 7 11:32:46 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/

Received: from nmemonix.com (www.nmemonix.com [195.74.128.200])
	by dorothy.denveronline.net (8.9.3/8.9.3) with SMTP id QAA27048
	for <jdom-commits at jdom.org>; Mon, 7 Aug 2000 16:54:12 -0600 (MDT)
From: bmclaugh at cvs.jdom.org
Received: (qmail 5747 invoked by uid 515); 7 Aug 2000 22:53:19 -0000
Date: 7 Aug 2000 22:53:19 -0000
Message-ID: <20000807225319.5746.qmail at nmemonix.com>
To: jdom-commits at jdom.org
Subject: [jdom-commits] CVS update: jdom/src/java/org/jdom
Sender: jdom-commits-admin at lists.denveronline.net
Errors-To: jdom-commits-admin at lists.denveronline.net
X-BeenThere: jdom-commits at lists.denveronline.net
X-Mailman-Version: 2.0beta2
Precedence: bulk
List-Id: JDOM Mailing List for CVS Commits <jdom-commits.lists.denveronline.net>

Date:	Monday August 7, 2000 @ 23:53
Author:	bmclaugh

Update of /home/cvspublic/jdom/src/java/org/jdom
In directory www.nmemonix.com:/tmp/cvs-serv5725/src/java/org/jdom

Modified Files:
	Document.java 
Log Message:
Fix to removeProcessingInstructions in Document.java, noted by Leo Moot (l.moot at chello.nl)


===================================================================
File: Document.java    	Status: Up-to-date

   Working revision:	1.13	Mon Aug  7 22:53:18 2000
   Repository revision:	1.13	/home/cvspublic/jdom/src/java/org/jdom/Document.java,v

   Existing Tags:
	start                    	(revision: 1.1.1.1)
	jdom                     	(branch: 1.1.1)




More information about the jdom-commits mailing list