title: Why I can't get the attributes from the root element using JDOM
body: <p>Lets consider this xml file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root attribute="value"&gt;
      &lt;element&gt;myElement&lt;/element&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I'm trying to parse the file using JDOM to extract the attribute name and value from the root element. </p>
  
  <p>This is the code I mad for this purpose :</p>
  
  <pre><code>public static org.jdom.Document document;
  public static org.jdom.Element root;
  
  SAXBuilder sxb = new SAXBuilder();
  try
  {
      document = sxb.build(new File("file.xml"));
      root = document.getRootElement();
  
      List myList = root.getAttributes();
      Iterator x = myList.iterator();
      while(x.hasNext())
      {
          Attribute myAttribute = (Attribute)x.next();
          System.out.println("name : " +  myAttribute.getName() + " &amp; value : " + myAttribute.getValue());
      }
  }
  catch(Exception e){
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Everything works fine for this xml file. But when I use this file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE rootElement PUBLIC "-//Project" "mydtd.dtd"&gt;
  &lt;root attribute="value"&gt;
      &lt;element&gt;myElement&lt;/element&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I get <code>Exception in thread "main" java.lang.NullPointerException</code></p>
  
  <p>Do you think I should remove the DOCTYPE from the xml file before parsing it and past it after I finish the parsing.</p>
  
  <p>Or there is something else I can do in this situation ?</p>
  
  <p>Thanks</p>