my dog learned polymorphism
The moose likes XML and Related Technologies and the fly likes Problem Parsing XML file with JDOM. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem Parsing XML file with JDOM." Watch "Problem Parsing XML file with JDOM." New topic

Problem Parsing XML file with JDOM.

Pallavi Mahajan

Joined: Apr 21, 2003
Posts: 12
Hello All,
I've just started working on JDOM and trying to parse XML file with JDOM.
I've set classpath to jdom.jar, xerces.jar and JDOM_HOME is properly set.
CLASSPATH: .;C:\Program Files\Common Files\Mercury Interactive\SharedFiles\JavaAddin\classes;C:\Program Files\Common Files\Mercury Interactive\SharedFiles\JavaAddin\classes\mic.jar;C:\CMVC95\CMVC\EXE\cmvc.jar;c:\jdk1.3.1_07\bin\.;c:\jdk1.3.1_07\lib\.;C:\jdom-b9\jdom-b9\build\.;C:\jdom-b9\jdom-b9\lib\xerces.jar;C:\jdk1.3.1_07\jre\lib\ext\.;
JDOM_HOME: C:\jdom-b9\jdom-b9\build\.;
JAVA_HOME: c:\jdk1.3.1_07;

C:\General>javac cannot access org.w3c.dom.Element
file org\w3c\dom\Element.class not found
Document d2 =[0]));
1 error
I'm getting above error. looks like:
import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.DOMBuilder;
import org.jdom.output.XMLOutputter;

public class EchoXML {
public static void main(String[] args) {

try {
//SAXBuilder saxbuild = new SAXBuilder();
DOMBuilder dombuild = new DOMBuilder();
//Document d = File(args[0]));
Document d2 =[0]));

XMLOutputter xmlout = new XMLOutputter("%%%%%");
xmlout.output(d2, System.out);
//xmlout.output(d2, System.out);
catch (Exception ex) {
Can anybody please help me in this error. I'm trying since few days and still I am there where I had started:-(
Thank You,
Pavel Halas
Ranch Hand

Joined: Jul 05, 2003
Posts: 35
It's hard to find your problem. But try this.

Joined: Jul 21, 2003
Posts: 23
The error message can't get any clearer than this:
"cannot access org.w3c.dom.Element"
You need to add the following line at the top your code (below any package statements)
import org.w3c.dom.*;

<a href="" target="_blank" rel="nofollow">MQMessenger</a> - free Java app for MQSeries
subject: Problem Parsing XML file with JDOM.
It's not a secret anymore!