using System; using System.Collections.Generic; using System.Text; using System.Xml; namespace HotelPms.Share.Xml { public class XmlOperation { /// ****************************** Description ******************************* /// žƒVƒXƒeƒ€–¼Ì /// @”Ä—pƒNƒ‰ƒX /// žŠT—v /// @XML‚Ì‘€ìF’ljÁAC³AíœAŒŸõ‚È‚Ç /// <>Žg—p•û–@ /// ž—š—ð /// @2007/11/10 ¬–؁@Ÿ—´ V‹Kì¬ /// ****************************** Declarations ****************************** #region ššššš@Declartions@ššššš private string fileName; private XmlDocument? xd; #endregion #region ššššš@Property@ššššš public string FileName { get { return fileName; } set { fileName = value; } } #endregion #region ššššš@Class Event@ššššš public XmlOperation() : this("") { } public XmlOperation(string fileName) { if (!fileName.Equals("")) { this.fileName = fileName; } xd = new XmlDocument(); xd.Load(this.fileName); } #endregion #region ššššš@Private Function@ššššš #endregion #region ššššš@Public Function@ššššš public XmlElement? AddNode(string parentXPath, string key, string value) { try { XmlElement ownerNode = (XmlElement)xd.SelectSingleNode(parentXPath); XmlElement newNode = xd.CreateElement(key); newNode.InnerText = value; ownerNode.AppendChild(newNode); return newNode; } catch { return null; } } /// /// Node‚ÌText‚̏C³ /// /// /// /// public bool SetNodeText(string xPath,string value) { try { xd.SelectSingleNode(xPath).InnerText = value; return true; } catch { return false; } } /// /// Node‚ÌText‚ðŽæ“¾‚·‚é /// /// /// public string GetNodeText(string xPath) { return xd.SelectSingleNode(xPath).InnerText; } /// /// NodeŒŸõ /// /// /// public XmlNode? SelectSingleNode(string xPath) { return xd.SelectSingleNode(xPath); } /// /// •Û‘¶‚·‚é /// /// public bool Save() { try { xd.Save(fileName); return true; } catch { return false; } } #endregion } }