我想在不知道它的索引的情况下获取xml文件的属性值,因为在xml文件中的多个元素中重复了属性。
这是我的xml文件
<fields>
<form name="userAdditionFrom">
</form>
</fields>
这是处理文件
case XMLEvent.ATTRIBUTE:
//how can i know the index of attribute?
String attName = xmlReader.getAttributeValue(?????);
break;
提前谢谢。
阿拉
最佳答案
如果它是XMLStreamReader,则可以使用getAttributeValue(int index)和getAttributeValue(String namespaceURI,String localName)来获取属性值。
从您的问题来看,您似乎正在混合使用Event和Cursor API。我已附加了“使用StAX”链接作为参考,以使您了解如何同时使用两者。
资源: