Read XML and and element if missing

My xml layout has changed since going into production. So, i need to read the file and, if the Facility element is missing, add it in.

Old xml:
<SrvConfig>
<HostAddress>dev123.home.com</HostAddress>
<WhsNumber>03</WhsNumber>
<SrvPath>/appl/03/wt4090/</SrvPath>
</SrvConfig>

Desired xml:
<SrvConfig>
<HostAddress>dev123.home.com</HostAddress>
<WhsNumber>03</WhsNumber>
<SrvPath>/appl/03/wt4090/</SrvPath>
<Facility>MFG</Facility>
</SrvConfig>

So my code to read it:

XmlNode node;
XmlDocument doc = new XmlDocument();

//open xml file
doc.Load(srvCfgPathAndName);

//find element of interest
node = doc.SelectSingleNode("/SrvConfig/HostAddress");
_currServerIP = node.InnerText;
node = doc.SelectSingleNode("/SrvConfig/WhsNumber");
_currWhs = node.InnerText;
node = doc.SelectSingleNode("/SrvConfig/SrvPath");
_currPath = node.InnerText;

//since Facility wasn't part of original design we
//may need to add it for existing devices
node = doc.SelectSingleNode("/SrvConfig/Facility");
if (node == null)
{
//somehow insert it and write it back out
}

Can someone help me out with the insert and write bit? Thanks!
[1615 byte] By [catlook] at [2007-11-20 8:55:18]
# 1 Re: Read XML and and element if missing
Create an element node, and then create a text node for it.
Then find the <SrvConfig> node, using SelectSingleNode, and use the AppendChild method.

XMLElement Facility = new XMLElement("","Facility","",doc);
Facility.AppendChild(new XMLText("MFG",doc));
doc.SelectSingleNode("/SrvConfig").AppendChild(Facility);
jkmyoung at 2007-11-10 3:26:45 >
# 2 Re: Read XML and and element if missing
How do I then save the file?
catlook at 2007-11-10 3:27:51 >