title: Retrieving Namespaces from Element in Java (using DOM)
body: <p>I have the following XML example:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
      xmlns:custom="http://example.com/opensearchextensions/1.0/"&gt;
      &lt;ShortName&gt;Test&lt;/ShortName&gt;
      &lt;Description&gt;Testing....&lt;/Description&gt;
      &lt;Url template="whatever" type="what" /&gt;
      &lt;Query custom:color="blue" role="example" /&gt;
  &lt;/OpenSearchDescription&gt;
  </code></pre>
  
  <p>My concern is with <code>Query</code> element. It has a Namespace attribute and, in java, you will need a <code>namespaceURI</code> to retrieve the value.</p>
  
  <p>My question is: How would I retrieve the list of namespaces from the root element (in this case, <code>OpenSearchDescription</code> element)? I want the attribute, prefix and namespace URI that I can use to request on <code>Query</code>.</p>
  
  <p>Thanks.</p>
  
  <p>PS: I'm using DOM in java, standard in Java SE. I'm willing to move to XPath, if it's possible. The requirement is that only the Java Standard API needs to be used.</p>