Codenameone HTMLParser gives NPE -
i getting npe while trying parse basic html string using htmlparser. code:
string html = "<html><body>test</body></html>"; htmlparser parser = new htmlparser(); system.out.println(parser); bytearrayinputstream ba = new bytearrayinputstream(html.getbytes()); system.out.println("ba::" + ba); inputstreamreader isr = new inputstreamreader(ba); system.out.println("isr1::" + isr); htmlelement root = parser.parsehtml(new inputstreamreader(new bytearrayinputstream(html.getbytes()))); hashtable info = root.getattributes(); set kys = data.keyset(); (object o : kys) { system.out.println("key::" + (string) o); system.out.println("value::" + (string) data.get(o)); }
stacktrace:
caused by: java.lang.nullpointerexception @ com.codename1.ui.html.htmlparser.parsetagcontent(htmlparser.java:81) @ com.codename1.xml.xmlparser.parse(xmlparser.java:267) @ com.codename1.ui.html.htmlparser.parsehtml(htmlparser.java:174) @ userclasses.statemachine.beforemain(statemachine.java:52)
am doing wrong here ?
you need utilize xmlparser
. htmlparser
designed utilize in htmlcomponent
.
codenameone
No comments:
Post a Comment