Unable to read XML properly using northwoods xml writer

Dear Support,
I have implemented xml writer and reader from one of the example from the samples. I have managed to write XML . I can get the correct XML as per graph on goDocument. But when i try to load(or read) the XML, I still get number of nodes same as that of original graph but their labels get changed. The same code which i implemented in my visual studio project gives correct writing and reading of xml for simple nodes(i.e. standard nodes as GoBoxNode, GoNode etc.). But when i change node class to my own cutomised class( which is inherited from GoBoxNode and has extra text boxes in it), it does not show labels properly though it creates(i.e. writes) XML with all nodes their properties: lebels, ports and links properly(which can be seen in XML). But when I try to read the XML and create a graph, it places labels wrongly though number of nodes created and their locations are same as that of original graph.
Could you please tell me what has went wrong in my class or its initialisation.

Thanks and regards,

Make sure the GoXmlBindingTransformer has a prototype of the node you are using.

If you need more than 1 line of code to create the node… the XML Reader has to do the same steps. Make sure all the
info needed (to set properties) is there in the AddBinding(s).

Open and look through XML to see if it really has the correct info.

Dear Jake,
Thanks for the reply. I have checked XML writer is writing XML properly. It shows all the node information along with its properties and also link information along with their to an from ports. But it is not reading the XML properly with the same transformer i used for writing the XML. It creates the diagram having same number of nodes and their location as that of original diagram. But their labels are different than that of original diagram. For instance, parent becomes the child and some childs change their labels. I am attaching here with this reply a XML, original diagram and diagram created after reading the XML.

For more information: this node is inherited from GoBoxNode(same as that of InfoNode2 in the samples). It contains 3 gotext boxes. middle for function Id, below two are verb and noun. Here in this example for top node i.e. parent node, FunctionID = F0, Verb = parent, Noun = node. This is just example.

Thanks and regards,

Dear Jake,
XML is not showing in last post. So I am puting XML again here with this post. One more important point to node is that the same code which i have implemented works fine with simple node like GoBoxNode and GoNode. I have checked my code just changing Node class to new node class(i.e. GoBoxNode). It writes and reads properly. It reads and recreates the diagram as that of the original diagram.

Thanks and regards,

Here’s the basics of storing a GoBoxNode in GoXml:

  ///   GoBoxNode XML
  GoBoxNode boxnodeT = new GoBoxNode();
  boxnodeT.LinkPointsSpread = true;
  boxnodeT.Port.IsValidDuplicateLinks = true;

  GoXmlBindingTransformer boxnodeTR = new GoXmlBindingTransformer("boxnode", boxnodeT);
  boxnodeTR.IdAttributeUsedForSharedObjects = true;
  boxnodeTR.HandlesNamedPorts = true;  // generate attributes for each of the named ports, specifying their IDs
  boxnodeTR.AddBinding("Text", "Text");
  boxnodeTR.AddBinding("LinkPointsSpread", "LinkPointsSpread");
  boxnodeTR.AddBinding("IsValidDuplicateLinks", "Port.IsValidDuplicateLinks");
  boxnodeTR.AddBinding("Location", "Location");

Note I’m setting LinkPointsSpread and Port.IsValidDuplicateLinks in both the prototype node and the XML. You really don’t need to do both. I think the best rule is to minimize the number of AddBindings to just the properties that change across nodes and links in your app.

For your node, you shouldn’t need:

    t.GeneratesPortsAsChildElements = true;
    t.BodyConsumesChildElements = true;

Dear Jake,
Thank you very much for the reply.
I have modified my binding and try to write and read the XML. Still I am getting the same problem. Actually in the last post I put same pictures of the graph but the after reading the XML it shifts its labels as given below;

Here it can be seen that number of nodes and their location is same as that of original diagram. But its labels get shifted and one of the child lebel vanishes. at the parent level in the new recreated diagram it gets the default label setting.

And as i said in the previous posts, it works for GoBoxNode i have already tried it. But it does not work for my cutomised node.

Thanks and regards,

can you post the before and after pics side-by-side? I’m not seeing a difference.

Dear Jake,
Sorry for not properly putting the pics in the post. I am attaching the pics side-by-side in this post.
Please find the below the pics of original graph and graph after reading XML.
Here, i just want to mention that by default for any new node, labels will be as “verb” and “noun”. That is while initializing, above labels are given to the new node created. But these can be editable by user.

Thanks and regards,

I have no idea how this could happen. If you can send me the project, I’ll take a look at it. Email it to “godiagram” at nwoods.

Ok. I will send it to you.
But How can I send it to you. Through email? I am not able to send it through mail. Instead I can paste here, my cutomised node class. This code also does not work for InfoNode2 from the samples. Please try writing and reading diagaram of InfoNode2 from samples. It does not work at my end. I just changed some of the labels in it. Please also try with below node(Function node). I am giving a dropbox link here to download the project please download the project form this link**(https://www.dropbox.com/s/yimeofxm/TestingXMLReadWrite.zip?dl=0).**
Function Node Class:

I have given complete project where XML reading and writing is implemented in my last post. Please let me know if you can not download the project.

Thanks and regards,

Here’s your problem… you need to implement CopyChildren helper in any class that has objects like this.

See what NodeLinkDemo does with myMessage in the InfoNode class.

I will check it with NodeLinkDemo and let you know whether it works or not.
Thank you very much for your reply.

Thanks Jake…
Yes that’s the problem…It is working fine now.
Thank you very much…
But I am curious, how did you find it out? Is any of the reading XML methods make use of CopyChildren method while reading it? And it does not use CopyChildren method while writing XML ? Could you please elaborate how did you arrived at this conclusion.
It will be helpful for me to find problems at my own as. I would appreciate if you provide me with the details on the way you approached this particular problem.


GoXml “copies” the prototype node to start each new node (or link). Forgetting CopyChildren is probably the most common error in creating new nodes, but we typically see the issue in Copy/Paste problems.

I knew as soon as I saw the “public GoText t1” that was probably the problem. Just something from experience.

Thank you very much for the reply.
I am still not getting, my code was writing the XML correctly but could not read it as it is. CopyChildren method is used while copying and pasting some of the goview elements. What is its relation with reading XML?

Thanks and regards,

The prototype node you create and pass into “new GoXmlBindingTransformer” is copied and then updated according to the XmlBindings for each in the XML.

Ok…prototype element is copied first and then its labels are updated as per Binding properties…
Thank you very much Jake