title: Get Attribute value of specfic tag
body: <p>I'm trying to extract the values of attributes "address" , "programmaticName" of the tags "datapoint" , "event" &amp; "command". The problem i'm facing is that i want to extract the values belonging to a particular protocol "BACNET" and not all the protocols in the XML file.</p>
  
  <p>XML FILE..</p>
  
  <pre><code>&lt;elementDefinitionModel manufacturerInSymbol="LIEBERT" minSupportedVersionInSymbol="1.4" modelInSymbol="DS070ADA0EI833A" modelQualifierInSymbol="DS070ADA0EI833A" symbolTag="LIEBERTDS070ADA0EI833ADS070ADA0EI833A"&gt;
  &lt;supportedprotocols&gt;
      &lt;supportedProtocol isSubscribable="true" protocolName="VELOCITY/IP"&gt;
      &lt;datapoints&gt;
          &lt;datapoint address="5327" deviceToNormal="VAL 10 /" nature="PARAMETRIC" programmaticName="val_ext_tmp_airDailyHigh" /&gt;
      &lt;/datapoints&gt;
      &lt;events&gt;
          &lt;event address="5015" programmaticName="evt_sys_tmpAirSupplyOver" values="a:3 a:11 a:19 a:27 i:0 i:4" /&gt;
      &lt;/events&gt;
      &lt;commands&gt;
          &lt;command access="RW" address="5008" deviceToNormal="VAL 10 /" division="CONFIGURATION" nature="PARAMETRIC" normalToDevice="VAL 10 *" programmaticName="val_sys_tmp_airSetPt" valueTypeInDevice="DATA_POINT_VALUE_TYPE_INTEGER" /&gt;
      &lt;/commands&gt;
      &lt;/supportedProtocol&gt;
      &lt;supportedProtocol isSubscribable="true" protocolName="BACNET:SITELINK_W-ICOM_PA71/RS-485"&gt;
      &lt;datapoints&gt;
          &lt;datapoint address="bs3_{PORTNUMBER}.85" nature="ENUM" programmaticName="st_sys_opStateCooling" valueTypeInDevice="DATA_POINT_VALUE_TYPE_INTEGER" /&gt;
      &lt;/datapoints&gt;
      &lt;events&gt;
          &lt;event address="bs2_{PORTNUMBER}.85" programmaticName="evt_sys_unitStandby" /&gt;
      &lt;/events&gt;
      &lt;commands&gt;
          &lt;command access="RW" address="m907_{PORTNUMBER}.85" division="CONFIGURATION" nature="PARAMETRIC" programmaticName="val_fan_pct_maxSetPt" valueTypeInDevice="DATA_POINT_VALUE_TYPE_INTEGER" /&gt;
      &lt;/commands&gt;
      &lt;/supportedProtocol&gt;
   &lt;/supportedprotocols&gt;
  &lt;/elementDefinitionModel&gt;
  </code></pre>
  
  <p>JAVA CODE..</p>
  
  <pre><code>    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      org.w3c.dom.Document document = db.parse(new File("C:\\Users\\aniruddh.mathur\\Desktop\\ds1.xml"));
      NodeList nodeList = document.getElementsByTagName("datapoint");
      for(int x=0,size= nodeList.getLength(); x&lt;size; x++) {              System.out.println(nodeList.item(x).getAttributes().getNamedItem("address").getNodeValue()+"\t"+nodeList.item(x).getAttributes().getNamedItem("programmaticName").getNodeValue());
      }
       System.out.println("\n");
       NodeList nodeList1 = document.getElementsByTagName("event");
      for(int x1=0,size1= nodeList1.getLength(); x1&lt;size1; x1++) {
      System.out.println(nodeList1.item(x1).getAttributes().getNamedItem("address").getNodeValue()+"\t"+nodeList1.item(x1).getAttributes().getNamedItem("programmaticName").getNodeValue());
      }
       System.out.println("\n");
       NodeList nodeList2 = document.getElementsByTagName("command");
      for(int x1=0,size1= nodeList2.getLength(); x1&lt;size1; x1++) {
      System.out.println(nodeList2.item(x1).getAttributes().getNamedItem("address").getNodeValue()+"\t"+nodeList2.item(x1).getAttributes().getNamedItem("programmaticName").getNodeValue());
         }
  </code></pre>
  
  <p>ACTUAL OUTPUT..</p>
  
  <pre><code>5327    val_ext_tmp_airDailyHigh
  bs3_{PORTNUMBER}.85 st_sys_opStateCooling
  
  
  5015    evt_sys_tmpAirSupplyOver
  bs2_{PORTNUMBER}.85 evt_sys_unitStandby
  
  
  5008    val_sys_tmp_airSetPt
  m907_{PORTNUMBER}.85    val_fan_pct_maxSetPt
  </code></pre>
  
  <p>EXPECTED OUTPUT..</p>
  
  <pre><code>bs3_{PORTNUMBER}.85 st_sys_opStateCooling
  
  bs2_{PORTNUMBER}.85 evt_sys_unitStandby
  
  m907_{PORTNUMBER}.85    val_fan_pct_maxSetPt
  </code></pre>