• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

My StartElement method doesn�t work

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic