Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jdom xpath runtime error

843834Apr 22 2003 — edited Oct 15 2003
First, I am a newbie.

I am getting an error while trying to use xpath and jdom. Here is the error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/saxpath/SAXPathEx
ception
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:140)
        at org.jdom.xpath.XPath.newInstance(XPath.java:133)
        at hello.main(hello.java:26)
Here is my code:
import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import org.jdom.xpath.*;
import java.util.*;

public class hello 
{
    
    
    public static void main( String args[] ) throws Exception {
    	
		System.out.println("Hello") ;
		System.out.println("Hello ugh") ;
		Document doc = new SAXBuilder().build("catalog.xml");
		List compositions = doc.getRootElement().getChildren("composition");
		for(int i=0; i < compositions.size(); i++) {
			String title = ((Element)compositions.get(i)).getChildText("title");
			
			//here i want to get the composer, will use xpath to find it
			//this line gets the 'key'
			String comp = ((Element)compositions.get(i)).getAttribute("composer").getValue();
			//this one does the xpath lookup
			XPath xpath = XPath.newInstance("composer");
			//List results = xpath.selectNodes(doc);
			
			System.out.println("  " + title + " -- " + comp );
						
		}
		System.out.println("Done:");	
    }
}
Thanks,
LNMEgo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2003
Added on Apr 22 2003
30 comments
447 views