使用DOM解析器解析XML中的属性

使用DOM解析器解析XML中的属性,第1张

使用DOM解析器解析XML中的属性

Node.getAttributes()

NamedNodeMap attributes = fstElmnt.getAttributes();for (int a = 0; a < attributes.getLength(); a++) {        Node theAttribute = attributes.item(a);        System.out.println(theAttribute.getNodeName() + "=" + theAttribute.getNodevalue());}

如果使用XPATH检索数据,则可以避免遍历。阅读本教程。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5506132.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-13
下一篇 2022-12-13

发表评论

登录后才能评论

评论列表(0条)

保存