I have a question concerning writing to XML files.
Currently I do
writer.RootElementName = “pnml”; ;
writer.Objects = this;
// Add Transformers for objects
// Save the file
Which works fine and produces files like
What I want to have is
… (data from the GoDocument.UserObject) …
Can somebody please give me a hint:
- How to add attributes to the RootElement? Just changing RootElementName does not help as this string appears in the closing clause as well.
- How to tread the GoDocument (named “net” here) my objects are living in as a parent object for XML export? Just adding a GoDocument Transformer does not help as the Document itself is not a member of the GoDocuments object enumeration. I want to do this because I would like to export more than one GoDocument to an XML file and I would like to store GoDocument specific information in my XML file.
Thanks for any help!
- Override GoXmlWriter.GenerateRootAttributes.
- Yes, define a transformer for your document class, and then set GoXmlWriter.Objects to a collection of your documents, instead of setting it to a single GoDocument.
Thank your very much! Worked out well.
After several month of working with GoDiagram now I have to say that one can do almost (wait my next posting )anything. But at least for me it turns out quite difficult to know which method to override. Like in this example: The answer is very easy but I was unable to find out on my own with the reference and user documentation. Maybe it is possible to extend the users documentation with a table containing commen overrides for different problems/requirements (like this GenerateRootAttributes in the XML chapter) at the end of each chapter.
That’s a good idea. Years ago we started putting in comments about how likely you would need to override a method, or whether you should even want to set a property. You’ll see some of that in the method descriptions for GoXML.
But anyway, that’s why we provide support.