I think you are confusing several different processing stages.
First, I assume you are completely familiar with using System.Xml.
Second, the construction of a node and its ports in memory should have nothing to do with the generation of XML that represents it.
You normally construct a GoGeneralNode by doing something like:
GoGeneralNode n = new GoGeneralNode();
n.Initialize(null, “someImage.type”, “top label string”, “bottom label string”, 3, 1);
n.Location = …;
That call to Initialize constructs three input ports and 1 output port, but you could pass zero and zero and do the construction of the ports individually:
GoGeneralNodePort p = n.MakePort(true); // an input port
p.Name = …; // and maybe set other properties too…
n.AddLeftPort§; // assume input ports are on left side
… then do the same for any other input ports …
p = n.MakePort(false); // an output port
p.Name = …;
n.AddRightPort§; // assume output ports are on the right side
Third, and quite independent of the construction of a node, is writing XML representing the node, its ports, and any links. You need to design the XML schema that you want to use, and then generate elements and attributes corresponding to the nodes/ports/links that you want to save. (I’m assuming you have the flexibility to design the XML format, and that you don’t have to generate a particular format that someone else has specified.)
If you look at the FlowCharter sample, you can see that in GraphDoc.Store it is storing the port IDs as attribute values in the element representing a node. It can do so because there are a fixed number of ports on a GraphNode in FlowCharter (at most 4). You need to decide if you can do the same, and if you want to. Another common alternative is to have separate nested elements, one per port. This allows for greater flexibility regarding the number of ports. Only you will know this for your particular application.
As a general rule, storing a document (whether XML or not) should not modify the contents of the document. So calling GoGeneralNode.AddLeftPort would be a no-no.
Fourth, the reading/loading of the XML does need to construct objects in memory, given the contents of the XML stream or DOM. As a general rule, loading a document should build a whole document and not use or refer to parts of any other document. Here is where you’ll want to construct a new node and call GoGeneralNode.MakePort, depending on the elements and attributes you read from the XML.
I think the sample applications also provide good examples of this.