我正在尝试从TagNode
. 问题是,有一个内部异常阻止它工作。这是我的电话:
CleanerProperties props = new CleanerProperties();
SimpleHtmlSerializer serializer = new SimpleHtmlSerializer(props);
changes.setHtmlForTimetable(serializer.getAsString(root));
root 当然不为空,显然序列化器也不为空。
这是堆栈跟踪:
01-21 23:42:50.860: W/System.err(25196): java.lang.NullPointerException
01-21 23:42:50.865: W/System.err(25196): at org.htmlcleaner.HtmlSerializer.isMinimizedTagSyntax(HtmlSerializer.java:54)
01-21 23:42:50.875: W/System.err(25196): at org.htmlcleaner.HtmlSerializer.serializeOpenTag(HtmlSerializer.java:189)
01-21 23:42:50.880: W/System.err(25196): at org.htmlcleaner.SimpleHtmlSerializer.serialize(SimpleHtmlSerializer.java:52)
01-21 23:42:50.885: W/System.err(25196): at org.htmlcleaner.Serializer.write(Serializer.java:249)
01-21 23:42:50.890: W/System.err(25196): at org.htmlcleaner.Serializer.getAsString(Serializer.java:176)
01-21 23:42:50.900: W/System.err(25196): at org.htmlcleaner.Serializer.getAsString(Serializer.java:197)
01-21 23:42:50.905: W/System.err(25196): at org.htmlcleaner.Serializer.getAsString(Serializer.java:206)
01-21 23:42:50.915: W/System.err(25196): at com.roneven.blich.GetChanges$1$1$1.callback(GetChanges.java:125)
01-21 23:42:50.920: W/System.err(25196): at com.roneven.blich.GetChanges$1$1$1.callback(GetChanges.java:1)
01-21 23:42:50.930: W/System.err(25196): at com.androidquery.callback.AbstractAjaxCallback.callback(AbstractAjaxCallback.java:501)
01-21 23:42:50.935: W/System.err(25196): at com.androidquery.callback.AbstractAjaxCallback.afterWork(AbstractAjaxCallback.java:1269)
01-21 23:42:50.940: W/System.err(25196): at com.androidquery.callback.AbstractAjaxCallback.run(AbstractAjaxCallback.java:993)
01-21 23:42:50.945: W/System.err(25196): at android.os.Handler.handleCallback(Handler.java:725)
01-21 23:42:50.945: W/System.err(25196): at android.os.Handler.dispatchMessage(Handler.java:92)
01-21 23:42:50.950: W/System.err(25196): at android.os.Looper.loop(Looper.java:137)
01-21 23:42:50.950: W/System.err(25196): at android.app.ActivityThread.main(ActivityThread.java:5191)
01-21 23:42:50.955: W/System.err(25196): at java.lang.reflect.Method.invokeNative(Native Method)
01-21 23:42:50.955: W/System.err(25196): at java.lang.reflect.Method.invoke(Method.java:511)
01-21 23:42:50.960: W/System.err(25196): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-21 23:42:50.960: W/System.err(25196): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
01-21 23:42:50.965: W/System.err(25196): at dalvik.system.NativeStart.main(Native Method)
更新:我找到了一种解决方法,甚至没有使用 HtmlSerializer 或 TagNode (使用我已经成功提取的 html 和一些字符串命令)