Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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.*;
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic