简体   繁体   English

在Android(API级别3)中从XML获取值

[英]Getting values from XML in Android (API Level 3)

I have a string that contains a xml structure and there are two pieces of data in separate tags that I am after. 我有一个包含xml结构的字符串,我要在单独的标记中包含两段数据。

xpath has been added since API level 8, and with me being stuck with API level 3 (old phone for you ;-)) I need a way to get the data. 从API级别8开始添加了xpath,而我被API级别3所困(适合您的旧电话;-)),我需要一种获取数据的方法。

Would using a regular expression commit a huge sin? 使用正则表达式会带来巨大的罪恶吗? ;-) The xml isn't that big... ;-) xml没那么大...

Looking for some guidance on what to. 寻找一些指导。

Many thanks! 非常感谢!

如果您添加了XML及其希望实现的结果,则可能会有所帮助,但是您应该能够使用DocumentBuilder解析XML字符串,这将返回一个Document ,并且您应该能够调用getElementsByTagName()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM