what is the best way to update an XML node value in C#?

My function iterates through every node of an instance of an XMLDocument. It checks to see if the current node's name is in a lookup list. If it is, it applies appropriate validation to the value of the current node.

When the validation method indicates that the value has been changed, I want to replace the value in the original document with the updated value.

I think the easiest way to achieve this might be to write out to an XMLTextWriter as I process each node in the original XMLDocument, either writing out the original or modified node and value as appropriate. This method would rely on determining whether the current node has any children, or is a stand-alone node.

Is there a better way I could update the values in the original document? I need to end up with the complete XMLDocument, but with updated node values, where appropriate.

Thanks in advance.


Can you not modify the existing nodes (which ate already in the correct structure and in an XMLDocument, then re-serialise the XMLDocument? If the nodes are simple text containters then the


property is the one you want.

Need Your Help

UIView in .XIB on Universal App always reports iPhone UI size

iphone objective-c ios ipad ios-universal-app

I am trying to port an iPhone app to iPad with as little work as possible and I am stuck on one last point.