Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Value on a node and link (Read 1709 times)
noen0909
YaBB Newbies
*
Offline


Hi, Everyone.

Posts: 9
Joined: May 20th, 2010
Value on a node and link
Jun 2nd, 2010 at 12:58pm
Print Post  
Hi,

I'm currently build a software that can draw Web service orchestration. and could generate an xml document as an ouput. my problem is, how do I get the value on each node that on screen so i could make an xml export file manually using xml writer. I'm aware that there's already a method such as saveToXml, but the result seems like to be not the one I'm looking for. So i decided to use xml writer manually instead.

here's an example :
there's a string value (could be integer or anything) on one of my node, how do i get that string value so i could write it on my xml document?

sorry for the bad English, and thank you so much for the reply.. even a little help will be much appreciated. Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Value on a node and link
Reply #1 - Jun 2nd, 2010 at 1:29pm
Print Post  
Hi,

If you are asking how to enumerate nodes and save custom data associated with their Tag, here's a possible way to do that:

Code
Select All
XmlDocument doc = new XmlDocument();

XmlElement parent = doc.CreateElement("services");
doc.AppendChild(parent);
foreach (ShapeNode node in diagram.Nodes)
{
	XmlElement service = doc.CreateElement("service");
	parent.AppendChild(service);
	service.SetAttribute("value", node.Tag.ToString());
}

doc.Save(@"test.xml"); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
noen0909
YaBB Newbies
*
Offline


Hi, Everyone.

Posts: 9
Joined: May 20th, 2010
Re: Value on a node and link
Reply #2 - Jun 2nd, 2010 at 2:26pm
Print Post  
Hi,

Thanks.. that's actually works like magic. But that's not entirely solve my current problem, but it sure did helps my progress.. Smiley a little note : i can't seem to run this phrase : node.Tag.ToString(); how do i add a tag on run time? i change that phrase with a string value in order to get the code working.

here's another question, if i can select all of the node using foreach, do that mean every node had been saved somewhere.. if so, how do i access it? such as get a link that in or out of it?

I'm sorry, I know it is noob question, I'm really new to all of this... then again, thank you so much for the reply.. even a little help will be much appreciated Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Value on a node and link
Reply #3 - Jun 2nd, 2010 at 2:37pm
Print Post  
Hi,

I thought you were saving some custom value in the Tag property. You can assign any kind of object to it, e.g. in the NodeCreated handler. If you keep your values in the node's Text property instead, just replace node.Tag.ToString() with node.Tag.

You can add nested loops over the node's IncomingLinks and OutgoingLinks collections to save information about the links associated with each node. Or after the nodes loop completes, you can iterate over diagram.Links to save the links separately.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint