SAX xml解析

前端之家收集整理的这篇文章主要介绍了SAX xml解析前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

今天又重新温习一下xml的三种解析,参考网址Android中解析XML,写得确实很好,写了三个例子,自己敲了一遍,很快就理解差不多了,但是看了一遍以后,想看深入一些,看看他的流程是什么,于是就在code中添加的打印堆栈的log,可以参考Android打印代码调用栈,以后遇到问题,可以添加这些log就能解决很多的事情了。看了一下,log信息如下:

D/congcl  ( 5074): startDocument trace: dalvik.system.VMStack.getThreadStackTrace(Native Method)
D/congcl  ( 5074): startDocument trace: java.lang.Thread.getStackTrace(Thread.java:591)
D/congcl  ( 5074): startDocument trace: com.project.xmlparse.model.parser.SaxBookParser$MyHandler.startDocument(SaxBookParser.java:110)
D/congcl  ( 5074): startDocument trace: org.apache.harmony.xml.ExpatParser.startDocument(ExpatParser.java:524)
D/congcl  ( 5074): startDocument trace: org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:473)
D/congcl  ( 5074): startDocument trace: org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
D/congcl  ( 5074): startDocument trace: org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
D/congcl  ( 5074): startDocument trace: javax.xml.parsers.SAXParser.parse(SAXParser.java:390)
D/congcl  ( 5074): startDocument trace: javax.xml.parsers.SAXParser.parse(SAXParser.java:187)
D/congcl  ( 5074): startDocument trace: com.project.xmlparse.model.parser.SaxBookParser.parse(SaxBookParser.java:38)
D/congcl  ( 5074): startDocument trace: com.project.xmlparse.MainActivity$1.onClick(MainActivity.java:39)
D/congcl  ( 5074): startDocument trace: android.view.View.performClick(View.java:4202)
D/congcl  ( 5074): startDocument trace: android.view.View$PerformClick.run(View.java:17340)
D/congcl  ( 5074): startDocument trace: android.os.Handler.handleCallback(Handler.java:725)
D/congcl  ( 5074): startDocument trace: android.os.Handler.dispatchMessage(Handler.java:92)
D/congcl  ( 5074): startDocument trace: android.os.Looper.loop(Looper.java:137)
D/congcl  ( 5074): startDocument trace: android.app.ActivityThread.main(ActivityThread.java:5039)
D/congcl  ( 5074): startDocument trace: java.lang.reflect.Method.invokeNative(Native Method)
D/congcl  ( 5074): startDocument trace: java.lang.reflect.Method.invoke(Method.java:511)
D/congcl  ( 5074): startDocument trace: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
D/congcl  ( 5074): startDocument trace: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
D/congcl  ( 5074): startDocument trace: dalvik.system.NativeStart.main(Native Method)

通过log信息很快就能定位它的执行流成了,主要的文件有SAXParser,ExpatParse,最后就已字节流的形式下发到底层,defaulthandler中的一些方法也都是在底层中上报调用的,代码 点击下载 原文链接:https://www.f2er.com/xml/300638.html

猜你在找的XML相关文章