title: Obtain tags, elements and change/add/delete these elements with lxml
body: <p>I want to get the different tags in the whole document, then get their attributes and compare them to what i want them to have (i.e. the title tag has the id attribute, but I want to change that attribute value and also want it to have the columns attribute)</p>
  <p>Here is an example of the xml code:</p>
  <pre><code> &lt;dita&gt;
          &lt;topic id=&quot;id15CDB0PL09E&quot;&gt;
              &lt;title id=&quot;id15CDB0R0VYB&quot;&gt;&lt;?FM MARKER [Header/Footer $1] All?&gt;Control
              &lt;/title&gt;
              &lt;shortdesc&gt;CONTROL&lt;/shortdesc&gt;
              &lt;concept id=&quot;id15CDB0Q0Q4G&quot;&gt;
                  &lt;title id=&quot;id15CDB0R0VHA&quot;&gt;General
                  &lt;/title&gt;
                  &lt;conbody&gt;
                      &lt;paragraph&gt;This section
                      &lt;/paragraph&gt;
                  &lt;/conbody&gt;
                  &lt;concept id=&quot;id156F7H00GIE&quot;&gt;
                      &lt;title id=&quot;id15CDB0R0V1W&quot;&gt;System
                      &lt;/title&gt;
                      &lt;conbody&gt;
                          &lt;paragraph&gt;Engine
                          &lt;/paragraph&gt;
                          &lt;paragraph&gt;The ECU
                          &lt;/paragraph&gt;
                          &lt;paragraph&gt;The aircraft
                          &lt;/paragraph&gt;
                          &lt;paragraph&gt;The system
                          &lt;/paragraph&gt;
                     &lt;/conbody&gt;
                  &lt;/concept&gt;
              &lt;/concept&gt;
          &lt;/topic&gt;
      &lt;/dita&gt;
  </code></pre>
  <p>And here is what I've been coding so far.</p>
  <pre><code>from lxml import etree
  import numpy as np
  
  tree = etree.parse(&quot;File.xml&quot;)
  root = tree.getroot()
  #Listas para guardar las tags
  Lista = []
  Atributos = []
  tags = []
  attributes = []
  #Muestra los tag-atributos:texto en forma de diccionario
  for element in root.iter():
      #Muestra las tags-atributos:texto
      #print(&quot;%s - %s : %s&quot; % (element.tag, element.attrib, element.text))
      Lista.append(element.tag)
      Atributos.append(element.attrib)
  #Muestra los valores unicos de las tags existentes
  tags = np.unique(Lista)
  attributes = np.unique(Atributos)
  print(tags)
  print(Atributos)
  tree.write(&quot;Resultado.xml&quot;)
  </code></pre>
  <p>But it causes an
  TypeError: '&lt;' not supported between instances of 'dict' and 'dict'</p>
  <p>The desired output is something like this</p>
  <pre><code>tags[topic,title,shortdesc,concept,conbody,para]
  attributes[topic:{id} title:{id,columns},shortdesc:None,concept:None,conbody:id,para:id]
  </code></pre>