saving graph as an xml file
-
hi i have created this method to display graph on a form and is display but the problem that i have is that i want to save this method as an xml file but i can't get it right.under this method there is code that i am trying to use to save this method as an xml file. private void DisplayTools() { Graph g = Graph("graph"); g.AddNode("Circle"); g.AddNode("Box"); g.AddNode("Ellipse"); g.AddNode("Diamond"); Edge e1 = (Edge)g.AddEdge("Circle", "Box"); Edge e2 = (Edge)g.AddEdge("Box", "Ellipse"); Edge e3 = (Edge)g.AddEdge("Ellipse", "Diamond"); Edge e4 = (Edge)g.AddEdge("Diamond", "Circle"); Node n1 = (Node)g.FindNode("Circle"); n1.Attr.Color = Microsoft.Glee.Drawing.Color.Black; n1.Attr.Shape = Shape.Circle; Node n2 = (Node)g.FindNode("Box"); n2.Attr.Color = Microsoft.Glee.Drawing.Color.Black; n2.Attr.Shape = Shape.Box; Node n3 = (Node)g.FindNode("Diamond"); n3.Attr.Color = Microsoft.Glee.Drawing.Color.Black; n3.Attr.Shape = Shape.Diamond; gViewer1.Graph = g; here is code that i am trying to use to save as an xml file FileStream fs = new FileStream("methods.xml", FileMode.Create); XmlTextWriter w = new XmlTextWriter(fs,Encoding.UTF8); w.WriteStartDocument(); w.WriteStartElement("methods"); DisplayTools(); w.WriteEndElement(); w.WriteEndDocument(); w.Flush(); fs.Close();
Mamphekgo
-
hi i have created this method to display graph on a form and is display but the problem that i have is that i want to save this method as an xml file but i can't get it right.under this method there is code that i am trying to use to save this method as an xml file. private void DisplayTools() { Graph g = Graph("graph"); g.AddNode("Circle"); g.AddNode("Box"); g.AddNode("Ellipse"); g.AddNode("Diamond"); Edge e1 = (Edge)g.AddEdge("Circle", "Box"); Edge e2 = (Edge)g.AddEdge("Box", "Ellipse"); Edge e3 = (Edge)g.AddEdge("Ellipse", "Diamond"); Edge e4 = (Edge)g.AddEdge("Diamond", "Circle"); Node n1 = (Node)g.FindNode("Circle"); n1.Attr.Color = Microsoft.Glee.Drawing.Color.Black; n1.Attr.Shape = Shape.Circle; Node n2 = (Node)g.FindNode("Box"); n2.Attr.Color = Microsoft.Glee.Drawing.Color.Black; n2.Attr.Shape = Shape.Box; Node n3 = (Node)g.FindNode("Diamond"); n3.Attr.Color = Microsoft.Glee.Drawing.Color.Black; n3.Attr.Shape = Shape.Diamond; gViewer1.Graph = g; here is code that i am trying to use to save as an xml file FileStream fs = new FileStream("methods.xml", FileMode.Create); XmlTextWriter w = new XmlTextWriter(fs,Encoding.UTF8); w.WriteStartDocument(); w.WriteStartElement("methods"); DisplayTools(); w.WriteEndElement(); w.WriteEndDocument(); w.Flush(); fs.Close();
Mamphekgo