help me that i am working in a sax parser project. it moves inside start and end document but not into start and end element.
Samudricka 0 Newbie Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
Let me ask you a question. Why should we helping you when what you always does is drop a general question and demand answers, do not provide any supporting coding with the task you facing? Not even the part of code that you having problem with...
Do not take it wrong, but if you not make it easier for us to understand what exactly is the problem we can come with many suggestions that will lead to different outcomes. Just look back to your post http connection.
Samudricka 0 Newbie Poster
public void startSax( String xmlBlkStr) {
try {
//
// turn it into an in-memory object.
//
//Parser parser;
byte xmlByteAray[];
ByteArrayInputStream byteStrm = null;
InputSource xmlBlk = null;
xmlByteAray = xmlBlkStr.getBytes();
if(xmlByteAray!=null) {
byteStrm = new ByteArrayInputStream(xmlByteAray);
if(byteStrm!=null) {
xmlBlk = new InputSource(byteStrm);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp= spf.newSAXParser();
//String validation = System.getProperty( "javax.xml.parsers.validation", "false");
//if (validation.equalsIgnoreCase("true"))
spf.setValidating(true);
sp.parse(xmlBlk,new saxparser());
// sp.parse(xmlBlk, new SaxErrorHandler());
//parser = sp.getParser();
//parser.setDocumentHandler(new saxparser());
//parser.setErrorHandler(new SaxErrorHandler());
// parser.parse(xmlBlk);
}
}
} catch (SAXParseException err) {
// PIPDebug.debugMsg("###Parsing error see teh XMLBlkStr " + xmlBlkStr);
// PIPDebug.debugMsg("** Parsing error"
// + ", line " + err.getLineNumber()
// + ", uri " + err.getSystemId());
// PIPDebug.debugMsg(" " + err.getMessage());
} catch (SAXException e) {
Exception x = e;
//if (e.getException() != null)
// x = e.getException();
x.printStackTrace();
} catch (Throwable t) {
t.printStackTrace();
}
}
......................................
class saxparser extends DefaultHandler
{
public void startDocument()throws SAXException {
//PIPDebug.debugMsg("Document Start...");
System.out.println("Document Start...");
}
public void startElement(String name, Attributes atts)throws SAXException {
System.out.println("parsing...");
processTag(name, true, atts);
}
public void characters(char[] ch, int start, int length)throws SAXException {
if((getIFQry || getSQLQry || getColVal) && (length > 0))
theValue.append(ch,start,length);
}
public void endElement(String name)throws SAXException {
processTag(name, false, null);
}
public void endDocument()throws SAXException {
System.out.println("Inside endDocument...");
}
}
SORRY FOR BEFORE MISTAKE HERE I HAVE GIVEN PART OF CODING...................
Samudricka 0 Newbie Poster
hi ,
i have solved my problem since if you noticed i would not have changed a main point that is as i have given below now it is working,.................. public void startElement(String name,String localName, String qname, Attributes atts)throws SAXException {...............}
Samudricka 0 Newbie Poster
now there si new problem that i get following error..........java.lang.NullPointerException
and i have found reason since start element variable is of void type.......can we change it into return type .........thanks in advance...........
my code is below
.................public void startElement(String name,String localName, String qname, Attributes atts)throws SAXException {
processTag(qname, true, atts);
stack.push(qname);
System.out.println("Append--->"+ name+"-->"+qname+" -->"+atts);
// System.out.println(p.accept.append("i"));
[B] p.accept.append("Append--->"+ name+"-->"+qname+" -->"+atts);[/B] /* if(qname.equals("ROW")){
mid.accept.append("qname-->"+qname);
}*/
}........................
it is part of it whereas other values arebelow..........
public port p;..........midlet class........
public Form accept;...............
the error is shown around bold and in midlet class there is no void type methods..........
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.