title: Parse xml tag attributes using Javascript or Jquery?
body: <p>I have one xml. Example XML is given below</p>
  
  <pre><code>&lt;company sample="text"&gt;
  &lt;employee id="001" sex="M" age="20"&gt;Premshree Pillai&lt;/employee&gt;
  &lt;/company&gt;
  </code></pre>
  
  <p>I need to get company attribute sample value</p>
  
  <p>I am trying this method</p>
  
  <pre><code>&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  window.onload = function() {
  var currLoanXml = '&lt;company sample="text"&gt;&lt;employee id="001" sex="M" age="20"&gt;Premshree Pillai&lt;/employee&gt;&lt;/company&gt;';
  var pic = $(currLoanXml).find('company').attr('sample');
  alert(pic);
  };
  &lt;/script&gt;
  </code></pre>
  
  <p>Its Shows Undefined in my alert box.</p>
  
  <p>But i can also alert this child tag its working</p>
  
  <pre><code>var pic = $(currLoanXml).find('employee').attr('id');
  alert(pic);  
  </code></pre>
  
  <p>What is a problem. I need to get first tag attributes. Please help me. </p>