help needed- newbie trying to setup xerces XML pasrer

Hello all,

I am new to Java and XML.

I am trying to write a simple java program that will use the xerces parser and will read the XML file.

I have installed xerces 2.8.0 and put in on a specific location on my hard drive.

I also added the xercesImpl.jar file to the CLASSPATH variable.

I am trying to compile this code:

import org.xml.sax.XMLReader;

public class SAXParserDemo {

/

public void performDemo(String uri) {

System.out.println("Parsing XML File: " + uri + "\n\n");

// Instantiate a parser

XMLReader parser = new SAXParser();

}

public static void main(String[] args)

{

if (args.length != 1)

{

System.out.println("Usage: java SAXParserDemo [XML URI]");

System.exit(0);

}//IF

String uri = args[0];

SAXParserDemo parserDemo = new SAXParserDemo();

parserDemo.performDemo(uri);

}//MAIN

}

The error I get is on this line : XMLReader parser = new SAXParser(); stating that it cannot find SAXParser.

What am I doing wrong? is there something else I need to import?

Help will be much appreciated.

Sorry for the newbie question.

Cheers,

Mike

[1235 byte] By [mikejordana] at [2007-10-3 4:37:20]
# 1

> The error I get is on this line : XMLReader parser =

> new SAXParser(); stating that it cannot find

> SAXParser.

> What am I doing wrong? is there something else I need

> to import?

Well, yeah. Your code shows you already know how to use the "import" statement. The compiler says it can't find SAXParser, and you correctly suspect that you need to import something. So the logical step: you need to import SAXParser.

But you don't know what package it's in, right? Well let me just look it up in the API documentation for you... here it is... javax.xml.parsers.SAXParser. Take note of the existence of documentation for the next time you have this sort of question.

http://java.sun.com/j2se/1.5.0/docs/api/

DrClapa at 2007-7-14 22:41:03 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
whenever an error says it can't find some class then first check if you are importing that class correctly.Then check if you have the classpath set up properly.
discussjava.com_a at 2007-7-14 22:41:03 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...