Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem Parsing XML file with JDOM.

 
Pallavi Mahajan
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 EchoXML.java
EchoXML.java:17: cannot access org.w3c.dom.Element
file org\w3c\dom\Element.class not found
Document d2 = dombuild.build(new java.io.File(args[0]));
^
1 error
I'm getting above error.
EchoXML.java looks like:
import java.io.*;
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 = saxbuild.build(new File(args[0]));
Document d2 = dombuild.build(new java.io.File(args[0]));

XMLOutputter xmlout = new XMLOutputter("%%%%%");
xmlout.output(d2, System.out);
System.out.println("\n----------------------------");
//xmlout.setTrimText(true);
//xmlout.setIndent(false);
//xmlout.output(d2, System.out);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
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,
Pallavi
 
Pavel Halas
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's hard to find your problem. But try this.
 
Naren
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.*;
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic