package org.apache.xerces.parsers does not exist
807607Dec 18 2006 — edited Dec 18 2006Can someone please help me in this code I am trying this since for a long time.
/*My code is this*/
/*I am trying to traverse an XML document using xerces*/
import org.apache.xerces.parsers.*;
import org.w3c.dom.*;
public class BasicDOMExample{
public static void main(String[] args)
{
if(args.length>0)
{
String filename=args[0];
BasicDOMExample exampleDOM= new BasicDOMExample(filename);
}
}
public BasicDOMExample(String filename)
{
try
{
//Parse in XML file and create a document
DOMParser parser=new DOMParser();
parser.parse(filename);
Document document = parser.getDocument();
}
catch (Exception e)
{
e.printStackTrace(System.err);
}
DOMImplementation domImp1=document.getImplementation();
boolean levelCoreSupport=domImpl.hasFeature("CORE","1.0");
if(levelCoreSupport)
System.out.println("DOM implementation supports DOM level 1.0 Core");
else
System.out.println("DOM implementation does not support level 1.0 Core");
Element documentElement=document.getDocumentElement();
System.out.println("Document node name: " + documentElement.getTagName());
}
}
/*My error list is this:*/
BasicDOMExample.java:1: package org.apache.xerces.parsers does not exist
import org.apache.xerces.parsers.*;
^
BasicDOMExample.java:21: cannot find symbol
symbol : class DOMParser
location: class BasicDOMExample
DOMParser parser=new DOMParser();
^
BasicDOMExample.java:21: cannot find symbol
symbol : class DOMParser
location: class BasicDOMExample
DOMParser parser=new DOMParser();
^
BasicDOMExample.java:31: cannot find symbol
symbol : variable document
location: class BasicDOMExample
DOMImplementation domImp1=document.getImplementation();
^
BasicDOMExample.java:32: cannot find symbol
symbol : variable domImpl
location: class BasicDOMExample
boolean levelCoreSupport=domImpl.hasFeature("CORE","1.0");
^
BasicDOMExample.java:38: cannot find symbol
symbol : variable document
location: class BasicDOMExample
Element documentElement=document.getDocumentElement();
^
6 errors
My Classpath (environment variable is this)
C:\Program Files\Java\jdk1.6.0\bin;C:\xerces\xerces-1_4_4;C:\DOM4J\dom4j-1.6.1.jar