I am trying to parse XML using SAX . After getting an instance of
SAXParser, I am trying to parse using
parser.parse( uri , new MyHandler() );
where uri - filename in URI form .
But I am getting the exception
org.xml.sax.SAXParseException: The processing instruction must begin
with the name of the target.
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1171)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at SAXTest.<init>(SAXTest.java:24)
at SAXTest.main(SAXTest.java:14)
Exception in thread "main"
Can anybody tell me what could be the problem . The code is given
below
Thanks in advance
Remesh
--------------------code-------------------------------
import java.io.* ;
import javax.xml.parsers.*;
import org.xml.sax.*;
public class SAXTest
{
public static void main( String[] args ) throws Exception
{
String fileName = "d:\\brett\\test1.xml" ;
String path = new File( fileName ).toURL().toString() ;
System.out.println( path );
SAXTest st = new SAXTest( path ) ;
}
public SAXTest( String uri ) throws Exception
{
SAXParserFactory spf = SAXParserFactory.newInstance() ;
spf.setValidating(true);
SAXParser parser = spf.newSAXParser();
parser.parse( uri , new MyHandler() );
}
class MyHandler extends HandlerBase
{
}
}
Cheers
Alex