title: How to remove an attribute from xml element?
body: <p>I'm using spring java to parse an xml.</p>
  <p>The xml contains the following element:</p>
  <pre><code> &lt;component xmlns=&quot;&quot;&gt;
        &lt;nonXMLBody classCode=&quot;DOCBODY&quot; moodCode=&quot;EVN&quot;&gt;
           &lt;text mediaType=&quot;application/pdf&quot; representation=&quot;B64&quot;&gt;zzz&lt;/text&gt;
        &lt;/nonXMLBody&gt;
   &lt;/component&gt;
  </code></pre>
  <p>I need to remove the attribute <code>xmlns=&quot;&quot;</code>.</p>
  <p>I'm have the following code but the attribute <code>xmlns=&quot;&quot;</code> is still there.</p>
  <pre><code>Document dom = null;
  try {
                      dom = xmlDocBuilder.parse(inpSource);
                  } catch (SAXException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  NodeList nodeComponent = dom.getElementsByTagName(&quot;component&quot;);
  Element element = (Element) nodeComponent.item(0);
  element.removeAttribute(&quot;xmlns&quot;);
  </code></pre>