开发者

how to get the value of attribute processing by STAX using java language?

i want to get the value of attribute of xml file without knowing it's index, since attributes are repeated in more than one element in the xml file.

here is my xml file

<fields>
  <form name="userAdditionFrom"> 
  </form>
</fields>

and here is the procssing file

 case XMLEvent.ATTRIBUTE:
      //how can i know the index of attribute?
       String attName = xmlReader.getAttributeValue(?????); 
 开发者_如何学运维      break;

thanx in advance.

Alaa


If it is XMLStreamReader then getAttributeValue(int index) and getAttributeValue(String namespaceURI, String localName) can be used to get attribute value.

From your question it look like you are using mix of Event and Cursor API. I have appended Using StAX link for your reference that gives idea how to use both.

Resources:

  1. XMLStreamReader getAttributeValue(String, String) JavaDoc Entry
  2. Using StAX
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜