File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes My StartElement method doesn�t work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "My StartElement method doesn�t work" Watch "My StartElement method doesn�t work" New topic
Author

My StartElement method doesn�t work

Luis Felipe Bacca Arango
Greenhorn

Joined: May 26, 2003
Posts: 27
Hi Guys, I have a question, i follow a guide from Sun about a Sax Parser, but my startElement method does not work.

I post my code here :

import org.jdom.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.parsers.*;

public class LeeValidaciones extends DefaultHandler{

static String filename = "C:\\eclipse\\workspace\\VALIDADOR_1.6.0_req_1056_1101_1102_1099_1026_1029\\desc\\descriptorReglas.xml";

public static void main(String[] args) {
try {
DefaultHandler dh = new LeeValidaciones();
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(filename,dh);
} catch (Exception e) {

e.printStackTrace();
}

}

public void startDocument() throws SAXException {
System.out.print("aaaa");
}

public void endDocument() throws SAXException {
System.out.print("fin");
}

public void startElement(String namespaceURI, String sName, String qName, Attribute attrs) throws SAXException{
System.out.print("bbbb");

}

I appreciate if somebody help me in this.

Thanks and Regards,


Luis Felipe.<br /> <br />SCJP, SCWCD.
Joe Hepp
Greenhorn

Joined: Feb 07, 2005
Posts: 12
Originally posted by Luis Felipe Bacca Arango:
public void startElement(String namespaceURI, String sName, String qName, Attribute attrs) throws SAXException{


Luis,

Your last parameter to the method needs to be of type Attributes, not Attribute.

Here is a website about SAX I used when first dealing with SAX.

SAX

It's an old site but still has the basics.

Joe
[ February 07, 2005: Message edited by: Joe Hepp ]
Luis Felipe Bacca Arango
Greenhorn

Joined: May 26, 2003
Posts: 27
Joe, thanks a lot.

It all work now.

I am very happy, now and going visit your suggest web site about sax.

Regards and see you,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My StartElement method doesn�t work