Update XML attribute

Hi

Now i can sucessfully store node,port and link information in XML file and also can read and display diagram.
now if i double click on perticular node then i should able to update its attribute like position,lable etc.
In that case how should i change only perticular attribute of node in XML file?

If you are writing XML to a file/stream/writer, you have to write everything, so “changing” a particular element doesn’t make sense.

So you must have a DOM in memory. You presumably have some sort of "key" associated with your GoNode -- it might be the PartID or the UserFlags or in the UserObject property or some property that you have added to the node class.
There are a number of ways of finding a particular XmlNode in an XmlDocument given a key -- you can iterate through the document and check for the XmlNode that has the key that you want, or you could query the document using XPath. I suggest you read about how to find information in XML DOM in any good book about XML.

can u plz explain further how to update XML nodes attribute.
Can u plz give example.

OK, let’s assume each of your GoNodes corresponds to a particular XmlElement in your DOM. How are you going to find that XmlElement so that you can modify one of its attributes? Does each node have a unique name or ID or some combination of properties? Or do you just keep a reference to the XmlElement as the GoNode.UserObject?

ye…while saving info in XML file m also saving PartId so my XML file is lookiing like

<?xml version="1.0" encoding="utf-8"?>












and on doubleclicking object i m passing partid. now how to proceed further??
So you are just working with a DOM in memory, right? You're not actually writing out everything to a file?
If you are working with a DOM in memory, then you just need to iterate over the child elements of the root node, and look for an element that has a "PartId" attribute value that matches what you are looking for. Then you can just call XmlElement.SetAttribute.
By the way, the inclusion of elements inside the elements seems superfluous in your example XML file.

yes…its working with SetAttribute
thanks