• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Problem Parsing XML file with JDOM.

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's hard to find your problem. But try this.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.*;
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic