NodeWrangler ClassCleanCode C# Libraries v1.2.03 API
Provides convenience methods for changing one or more individual text nodes in an XML file.
Inheritance Hierarchy

OnlineSystem Object
  CleanCode.Xml NodeWrangler

Namespace: CleanCode.Xml
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax

public class NodeWrangler
Remarks

To use, create an object, specifying an XML file, then load the file.
NodeWrangler nodeWrangler = new NodeWrangler(filename);
if (!nodeWrangler.LoadXml())
{ return filename + ": cannot load"; }
string oldStuff = nodeWrangler.ReadNode(MY_NODE);
if (oldStuff == null)
{ return filename + ": " + MY_NODE + ": cannot locate node"; }
if (oldStuff.Equals(newStuff))
{ return "oldStuff already set to [" + newStuff + "]"; }
if (!nodeWrangler.UpdateNode(MY_NODE, newStuff))
{ return filename + ": " + MY_NODE + ": cannot locate node"; }
if (!nodeWrangler.WriteXml())
{ return filename + ": cannot write"; }
Then, make any changes for each node of interest. In this code fragment, we read a text node, see if it already matches what we want to change it to, and if not, change it. Finally, save the changes you have made:

Since CleanCode 0.9.07.

See Also