public void PopulateServerForm()
{
XmlDocument myDoc = new XmlDocument();
myDoc.Load(@"C:\myFile.xml");
string ipAddressXpath = string.Format("Setup/ACSP/Primary/IPAddress");
string ipPortXpath = string.Format("Setup/ACSP/Primary/IPPort");
string configPathXpath = string.Format("Setup/ACSP/Primary/ConfigurationPath");
txtIPAddress.Text = ReadValueFromXmlDocumentAtXPath(myDoc, ipAddressXpath);
txtIPPort.Text = ReadValueFromXmlDocumentAtXPath(myDoc, ipPortXpath);
txtConfigPath.Text = ReadValueFromXmlDocumentAtXPath(myDoc, configPathXpath);
}
public string ReadValueFromXmlDocumentAtXPath(XmlDocument myDoc, string xpath)
{
string value = string.Empty;
XmlNode myNode= myDoc.SelectSingleNode(xpath);
if(myNode != null && myNode.InnerText != null)
{
value = myNode.InnerText;
}
return value;
}
|