java - SAX parser not completely working inside swing worker thread -
i tried couldn't working:
@override protected void doinbackground() throws exception { // code uses online stream , parse xml. class saxhandler extends defaulthandler { @override public void startelement(string uri, string localname, string qname, attributes attributes) throws saxexception { system.out.println(qname); switch (qname) { case "requiredname": // code create new node break ; } } @override public void characters(char[] ch, int start, int length) throws saxexception { content = string.copyvalueof(ch, start, length).trim(); } @override public void endelement(string uri, string localname, string qname) throws saxexception { system.out.println("---" + qname + "---"); switch (qname) { case "closing tag": publish(object); } } } url url = new url("http://feeds.feedburner.com/blogspot/infogate"); httpurlconnection con = (httpurlconnection)url.openconnection(); con.connect(); inputstream stream = con.getinputstream(); saxparserfactory spfac = saxparserfactory.newinstance(); saxparser parser = spfac.newsaxparser(); saxhandler handler = new saxhandler(); system.out.println("i here"); parser.parse(stream, handler); }
for testing purposes, want parser writes out tags name encounters while parsing xml. writes starting tags , not parse more.
if go xml page , view source able see tags. parsing tags of starting line first <title>
tag.
update: code parsing working fine in separate class not working when written inside swing worker thread's doinbackground()
method.
everything else in application ready , stuck on part.
Comments
Post a Comment