Question

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

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top