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.
The code iterates through my array and lists all objects that are not null.
FileOutputStream os = new FileOutputStream("C:\\Users\\David Laptop\\Documents\\Doc1.xml");
XMLEncoder encoder = new XMLEncoder(os);
for( int x = 0; x < 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();
I get this outcome:
?xml version="1.0" encoding="UTF-8" ?> java version="1.7.0_40" class="java.beans.XMLDecoder"> string dad
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!
No comments:
Post a Comment