To use DOM to access XML files, you must link the XML file to the HTML web page.
#region 2 small functions for reading and writing xml files, 2005 4 2 by hyc
public void SetXmlFileValue(string xmlPath, string AppKey, string AppValue)//Write xmlPath is the file path + file name, AppKey is Key Name, AppValue is Value
{
XmlDocument xDoc = new XmlDocument();
(xmlPath);
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = ("//appSettings");
xElem1 = (XmlElement)("//add[@key='" + AppKey + "']");
if ( xElem1 != null )
{
("value",AppValue);
}
else
{
xElem2 = ("add");
("key",AppKey);
("value",AppValue);
(xElem2);
}
(xmlPath);
}
public void GetXmlFileValue(string xmlPath, string AppKey, ref string AppValue)//Read xmlPath is the file path + file name, AppKey is Key Name, AppValue is Value
{
XmlDocument xDoc = new XmlDocument();
(xmlPath);
XmlNode xNode;
XmlElement xElem1;
xNode = ("//appSettings");
xElem1 = (XmlElement)("//add[@key='" + AppKey + "']");
if ( xElem1 != null )
{
AppValue= ("value");
}
else
{
// ("There is not any information!");
}
}
#endregion
#region 2 small functions for reading and writing xml files, 2005 4 2 by hyc
public void SetXmlFileValue(string xmlPath, string AppKey, string AppValue)//Write xmlPath is the file path + file name, AppKey is Key Name, AppValue is Value
{
XmlDocument xDoc = new XmlDocument();
(xmlPath);
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = ("//appSettings");
xElem1 = (XmlElement)("//add[@key='" + AppKey + "']");
if ( xElem1 != null )
{
("value",AppValue);
}
else
{
xElem2 = ("add");
("key",AppKey);
("value",AppValue);
(xElem2);
}
(xmlPath);
}
public void GetXmlFileValue(string xmlPath, string AppKey, ref string AppValue)//Read xmlPath is the file path + file name, AppKey is Key Name, AppValue is Value
{
XmlDocument xDoc = new XmlDocument();
(xmlPath);
XmlNode xNode;
XmlElement xElem1;
xNode = ("//appSettings");
xElem1 = (XmlElement)("//add[@key='" + AppKey + "']");
if ( xElem1 != null )
{
AppValue= ("value");
}
else
{
// ("There is not any information!");
}
}
#endregion