I am creating software that creates documents, (Bayesian network graphs to be exact), and these documents need to be saved in an XML format.
I know how to create XML files, but I have yet to decide how to organise the code.
At the moment, I plan on having each object (i.e. a Vertex or an Edge) have a function called getXML() (they will probably implement an interface so that it can be expanded later on). getXML() will return a string containing the XML for that object.
There will be another object which will collect all these XML strings and put them together, and output an XML file.
For some reason, I think this seems a bit messy, how would you recommend doing it?