title: Parsing XML from Curl output
body: <p>When querying my internal API I get a bunch of responses. Those responses will tell me if a specific service is up/down.</p>
  
  <p>Curl command:</p>
  
  <pre><code>curl https://myinternalapi.example.com/Ping/1.1
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;ping&gt;&lt;service name="FBcheckOnline" status="down"/&gt;&lt;service name="APICheckOn" status="up"/&gt;&lt;/ping&gt;
  </code></pre>
  
  <p>I would like to parse the output data using Python/Bash. With the data parsed, I can then create <code>if</code> statements to check if a specific service is up or down.</p>
  
  <p>The desired output would be something like:</p>
  
  <pre><code>FBcheckOnline down
  APICheckOn up
  </code></pre>
  
  <p>How can I do that using Python (2.7) or Bash?</p>
  
  <p><strong>EDIT 1</strong>: I managed to get it working with Python 2.7</p>
  
  <pre><code>from xml.dom import minidom
  xmldoc = minidom.parse('test.xml')
  items = xmldoc.getElementsByTagName('service')
  
  for item in items:
      print item.attributes['name'].value, 
      print item.attributes['status'].value
  </code></pre>
  
  <p>However, I am trying to make it parse the data from a <code>curl</code> command instead of a file... or make the curl command to send the output to a file and then read it.</p>