title: Remove nokogiri attribute based on namespace prefix
body: <p>I'm using nokogiri to parse an XML file. Some of the nodes in the file have attributes specific to namespaces:</p>
  
  <pre><code>&lt;metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"&gt;
      &lt;dc:identifier id="iden" opf:scheme="ISBN"&gt;xxxx&lt;/dc:identifier&gt;
      &lt;dc:creator opf:role="aut" opf:file-as="Name"&gt;xxxx&lt;/dc:creator&gt;
      &lt;dc:date opf:event="publication"&gt;xxxx&lt;/dc:date&gt;
      &lt;dc:publisher&gt;xxxx&lt;/dc:publisher&gt;
      &lt;meta name="cover" content="x"/&gt;
  &lt;/metadata&gt;
  </code></pre>
  
  <p>I'm trying to remove any attribute with the "opf" prefix. I've come across xpath solutions in finding an attribute <em>value</em> based on a partial match, but what about when it's a partial match of the attribute name itself? I tried a lot of things that haven't worked. I did a simple thing just to try to extract the attribute names at least, but if I do:</p>
  
  <pre><code>elements = @doc.at_xpath('//xmlns:metadata').children
  elements.each { |el|
      el.attributes.each { |attribute|
          if attribute[1].namespace_scopes[1].prefix == "opf"
              puts attribute[0]
          end
      }   
  }
  </code></pre>
  
  <p>I end up getting:</p>
  
  <pre><code>id
  scheme
  role
  file-as
  event
  name
  content
  </code></pre>
  
  <p>but I only want the ones with the "opf" prefix ("opf:scheme", "opf:role, "opf:file-as", "opf:event") so that they can be removed, without touching any of the other attributes. I even tried to force it by hard-coding the attributes I knew existed:</p>
  
  <pre><code>opf_attributes = ["opf:file-as","opf:scheme","opf:role","opf:event"]
  elements.each  { |el|
      opf_attributes.each { |x|
          el.remove_attribute(x) if el[x] != nil
      }
  } 
  </code></pre>
  
  <p>which is not the smartest way to go about this, but this still didn't work. Nothing happens to the nodes, and the attributes remain as they were. (I don't know if it's worth noting, but if I use the <code>remove_attr(x)</code> method instead, I get this error: <code>undefined method 'remove_attr' for #&lt;Nokogiri::XML::Element:0x...&gt;</code></p>
  
  <p>So, my question is:<br>
  Is there a clearer way to </p>
  
  <ol>
  <li>find attributes based on a partial match and/or the namespace prefix, then </li>
  <li>remove those attributes from the nodes that contain them?</li>
  </ol>