用于简单 xml 节点字符串的 Android XML 解析器 [英] Android XML parser for simple xml node strings

查看:43
本文介绍了用于简单 xml 节点字符串的 Android XML 解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要解析一系列来自持久套接字连接的简单 XML 节点(字符串格式).自定义 Android SAX 解析器真的是最好的方法吗?以这种方式

I need to parse a series of simple XML nodes (String format) as they arrive from a persistent socket connection. Is a custom Android SAX parser really the best way? It seams slightly overkill to do it in this way

我天真地希望我可以将字符串转换为 XML,然后使用点语法或类似语法引用名称/属性.

I had naively hoped I could cast the strings to XML then reference the names / attributes with dot syntax or similar.

推荐答案

我会使用 DOM 解析器.它的效率不如 SAX,但如果它是一个不太大的简单 XML 文件,它是最简单的起床和移动方式.

I'd use the DOM Parser. It isn't as efficient as SAX, but if it's a simple XML file that's not too large, it's the easiest way to get up and moving.

关于如何使用它的很棒的教程:http://tutorials.jenkov.com/java-xml/dom.html

Great tutorial on how to use it here: http://tutorials.jenkov.com/java-xml/dom.html

这篇关于用于简单 xml 节点字符串的 Android XML 解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆