在android中使用SAX解析属性
是否可以使用 SAX 解析器解析 xml 文件中的属性?
例如:我能够轻松解析:
<author>Hina2</author>
结果:Hina2
如何解析以下属性:
<text author="Hina2" timeModified="timestampgoeshere"
pos="pre" priority="0" thumbUrl="text2" url="textfull2"/>
谢谢!
Is it possible to parse attributes from an xml file using SAX parser?
ex: I am able to easily parse:
<author>Hina2</author>
Result: Hina2
How do I parse the attributes from:
<text author="Hina2" timeModified="timestampgoeshere"
pos="pre" priority="0" thumbUrl="text2" url="textfull2"/>
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
startElement 方法有 Attributes 作为参数。您可以从该参数获取元素的属性。您可以参考此链接来获取示例。
startElement method has Attributes as parameter. You can get attributes of element from that parameter. You may refer this link for example.
如果您使用 android sax 版本那么您可以像这样进行
if your using the android sax version then you can go about it like this