Welcome to android xml parser example using XMLPullParser. We will have a sample XML file that we will parse in android app and display it on the page.
欢迎使用XMLPullParser的android xml解析器示例。 我们将有一个示例XML文件,该文件将在android应用程序中解析并显示在页面上。
Android XML解析器 (Android XML Parser)
XML stands for Extensible Mark-up Language. XML files are commonly parsed in android to retrieve the relevant information from them. There are three types of android XML parser that we can use.
XML代表可扩展标记语言 。 XML文件通常在android中进行解析,以从中检索相关信息。 我们可以使用三种类型的android XML解析器。
- SAX Parsers SAX解析器
- DOM Parsers DOM解析器
- XMLPullParser XMLPullParser
DOM Parser : DOM parser use an object based approach where the whole xml is loaded into the memory and validated. Then it starts parsing the xml document. It parses from the starting node to the end node. Particular nodes cannot be parsed. Overall it’s slower than the other two.
DOM解析器 :DOM解析器使用基于对象的方法,其中将整个xml加载到内存中并进行验证。 然后,它开始解析xml文档。 它从起始节点解析到结束节点。 无法解析特定的节点。 总体来说,它比其他两个要慢。
SAX and XMLPullParser : These use an object based approach and are similar in terms of memory and performance. SAX is similar to DOM in the context that it begins parsing from top to bottom and there is no way to parse only particular nodes. On the contrary, XMLPullParser can parse particular nodes.
SAX和XMLPullParser :它们使用基于对象的方法,并且在内存和性能方面相似。 在上下文中,SAX与DOM相似,它开始从上到下进行解析