title: Recursive XML parsing python using ElementTree
body: <p>I'm trying to parse below XML using Python ElementTree to product output as below. I'm trying to write modules for top elements to print them. However It is slightly tricky as category element may or may not have property and cataegory element may have a category element inside.</p>
  
  <p>I've referred to previous question in this topic, but they did not consist of nested elements with same name</p>
  
  <p>My Code: 
  <a href="http://pastebin.com/Fsv2Xzqf" rel="noreferrer">http://pastebin.com/Fsv2Xzqf</a></p>
  
  <pre><code>work.xml:
  &lt;suite id="1" name="MainApplication"&gt;
  &lt;displayNameKey&gt;my Application&lt;/displayNameKey&gt;
  &lt;displayName&gt;my Application&lt;/displayName&gt;
  &lt;application id="2" name="Sub Application1"&gt;
  &lt;displayNameKey&gt;sub Application1&lt;/displayNameKey&gt;
  &lt;displayName&gt;sub Application1&lt;/displayName&gt;
  &lt;category id="2423" name="about"&gt;
  &lt;displayNameKey&gt;subApp.about&lt;/displayNameKey&gt;
  &lt;displayName&gt;subApp.about&lt;/displayName&gt;
  &lt;category id="2423" name="comms"&gt;
  &lt;displayNameKey&gt;subApp.comms&lt;/displayNameKey&gt;
  &lt;displayName&gt;subApp.comms&lt;/displayName&gt;
  &lt;property id="5909" name="copyright" type="string_property" width="40"&gt;
  &lt;value&gt;2014&lt;/value&gt;
  &lt;/property&gt;
  &lt;property id="5910" name="os" type="string_property" width="40"&gt;
  &lt;value&gt;Linux 2.6.32-431.29.2.el6.x86_64&lt;/value&gt;
  &lt;/property&gt;
  &lt;/category&gt;
  &lt;property id="5908" name="releaseNumber" type="string_property" width="40"&gt;
  &lt;value&gt;9.1.0.3.0.54&lt;/value&gt;
  &lt;/property&gt;
  &lt;/category&gt;
  &lt;/application&gt;
  &lt;/suite&gt;
  </code></pre>
  
  <p>Output should be as below:</p>
  
  <pre><code>Suite: MainApplication
      Application: Sub Application1
          Category: about
              property: releaseNumber | 9.1.0.3.0.54
              category: comms
                  property: copyright | 2014
                  property: os | Linux 2.6.32-431.29.2.el6.x86_64
  </code></pre>
  
  <p>Any pointers in right direction would be of help.</p>