title: How to set prefix for the attribute in xml using java
body: <p>I like to set prefix for attribute while creating <code>XML</code> file using <code>Java</code>.
  The result that I needed is </p>
  
  <pre><code>&lt;entry gd:etag="*"&gt;
      &lt;id&gt;Text&lt;/id&gt;
  &lt;/entry&gt;
  </code></pre>
  
  <p>But I'm getting</p>
  
  <pre><code>&lt;entry etag="*"&gt;
      &lt;id&gt;Text&lt;/id&gt;
  &lt;/entry&gt;
  </code></pre>
  
  <p>The code that I have written is     </p>
  
  <pre><code>DocumentBuilderFactory docBuildFactory = DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder = docBuildFactory.newDocumentBuilder();
  Document doc = docBuilder.newDocument();
  Element entry = doc.createElement("entry");
  entry.setAttribute("etag","*");
  doc.appendChild(entry);
  Element id = doc.createElement("id");
  id.setTextContent("Text");
  entry.appendChild(id);
  .....
  </code></pre>
  
  <p>I have no idea how to set prefix for the attributes. Can someone suggest me how to do this?</p>