title: How can i parse a xml file in python
body: <p>I have an xml file(basically the file is a jenkins slave config.xml file) from where i have to get certain values.
  So, i tried parsing the <code>xml</code> file using <code>Element Tree</code> something like  this</p>
  
  <pre><code>tree = ET.parse(config.xml)
  root = tree.getroot()
  print root
  for item in root.findall('slave'):
  </code></pre>
  
  <p>and then i am saving this parsed <code>xml</code> file in a text file, now i want to get the value within this tag 
  I can do it through <code>bash</code> but i want to know how can we do this in python
  Here goes the bash code</p>
  
  <pre><code>cat test.xml | sed -n 's:.*&lt;label&gt;\(.*\)&lt;/label&gt;.*:\1:p'
  </code></pre>
  
  <p>Here is a sample jenkins slave config.xml file</p>
  
  <pre><code>&lt;slave&gt;
  &lt;name&gt;some_name&lt;/name&gt;
  &lt;description/&gt;
  &lt;remoteFS&gt;some_value&lt;/remoteFS&gt;
  &lt;numExecutors&gt;xx&lt;/numExecutors&gt;
  &lt;mode&gt;EXCLUSIVE&lt;/mode&gt;
  &lt;retentionStrategy class="xxxx"/&gt;
  &lt;launcher class="xxxxx" plugin="xxxxx"&gt;
      &lt;host&gt;xxx.x.x.xx&lt;/host&gt;
      &lt;port&gt;xx&lt;/port&gt;
      &lt;credentialsId&gt;xxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx&lt;/credentialsId&gt;
      &lt;maxNumRetries&gt;0&lt;/maxNumRetries&gt;
      &lt;retryWaitTime&gt;0&lt;/retryWaitTime&gt;
      &lt;sshHostKeyVerificationStrategy class="hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy/&gt;&lt;/launcher&gt;
      &lt;label&gt;some_label&lt;/label&gt;
  &lt;/slave&gt;
  </code></pre>
  
  <p>Similarly as label i need other values as well such as hostname, port etc.</p>