title: Trying to convert an object array into XML, can't get object headers
body: <p>I'm using this XML converter, but I am not getting the object header to wrap each object's properties... I can't find a method in the encoder class to do this either. </p>
  
  <p>The code iterates through my array and lists all objects that are not null.</p>
  
  <pre class="lang-java prettyprint-override"><code>FileOutputStream os = new FileOutputStream("C:\\Users\\David Laptop\\Documents\\Doc1.xml");
  XMLEncoder encoder = new XMLEncoder(os);
  for( int x = 0; x &lt; people.length;x++)
    if (people[x] != null)
    {
      //header here?
      encoder.writeObject(people[x].getName());
      encoder.writeObject(people[x].getTelephoneNumber());
      encoder.writeObject(people[x].getEmailAddress());    
    }
  }
  encoder.close(); 
  </code></pre>
  
  <p>I get this outcome:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
  &lt;java version="1.7.0_40" class="java.beans.XMLDecoder"&gt;
  string
  dad&lt;/string  string 35235 /string 
  string email /string
  &lt;/java&gt;
  </code></pre>
  
  <p>If I do more object entries then it ends up being a big list which isn't helpful as another function I want to implement is reading from an XML file into the array... any help on that would also be useful! </p>
  
  <p>EDIT: New information based on the answer given:</p>
  
  <p>So is there no way to make this happen without a no-arg constructor? I've implemented the Serializable into both classes for good measure... I'm using this line to add new objects:  </p>
  
  <pre class="lang-java prettyprint-override"><code>mybook1.addRecord(new newPerson(Name,telephoneNumber,emailAddress));  
  </code></pre>
  
  <p>which uses this: </p>
  
  <pre class="lang-java prettyprint-override"><code>public void addRecord(newPerson c) 
  {
      people[numOfRecords] = c; 
      numOfRecords++;  
  }                                                               
  </code></pre>
  
  <p>below is the object itself:   </p>
  
  <pre class="lang-java prettyprint-override"><code>public class newPerson implements java.io.Serializable 
  {     
  
  private String Name; 
  private String telephoneNumber; 
  private String emailAddress;  
  
  public newPerson(String n, String t, String e) 
  { //local variables n,t,e only used in this method
      Name = n;
      telephoneNumber = t;
      emailAddress = e;
  }
  </code></pre>
  
  <p>Any suggestions?</p>