title: XMLEventReader Stax API not able to getName and value for Attribute in JDK 1.8
body: <p>I am using Stax XML EventReader for reading from xml. I have to verify a few tags in xml for which i am using the same. I am able to successfully read the tagname and characters from the xml but unable to read the attribute name and value. I am using jdk 1.8.111</p>
  
  <p><strong>XML:</strong></p>
  
  <pre><code>&lt;xml&gt;
  &lt;status request_id="fa844c52-daeb-4d24-920b-581ce2ac1afe1482232642212"     response_time="00:00:00:039"&gt;
  </code></pre>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>public static String XMLParseAttribute() throws XMLStreamException, IOException {
  
      XMLInputFactory inputFactory = XMLInputFactory.newInstance();
      in = IOUtils.toInputStream(URLResponse, "UTF-8");
      eventReader = inputFactory.createXMLEventReader(in);                
      XMLEvent event = eventReader.nextEvent();
  
          while(eventReader.hasNext())
          {
              XMLEvent event = eventReader.nextEvent();
  
                  if (event.isStartElement()) {
                      Iterator&lt;Attribute&gt; itr = event.asStartElement().getAttributes();
                      while(itr.hasNext()){
                          Attribute attribute = itr.next();
                          attribute. //get name and value here
                      }
                  }
               }
          //Something like this below
          return attribute.getName().toString();
          }
  </code></pre>
  
  <p>Kindly guide me as to how to use this XMLEventReader to read the attribute name and value.</p>