public static PHONG CreateObject(XmlElement node) { PHONG result = new PHONG(); result.m_ten = node.GetAttribute("loai"); result.m_dongia = float.Parse(node.GetAttribute("dongia")); if (node.GetAttribute("ngaygiam") != "") { result.m_ngaygiam = int.Parse(node.GetAttribute("ngaygiam")); } if (node.GetAttribute("mucgiam") != "") { result.m_mucgiam = int.Parse(node.GetAttribute("mucgiam")); } return(result); }
public void ReadXML(string FileName) { XmlDocument doc = new XmlDocument(); doc.Load(FileName); XmlElement root = doc.DocumentElement; m_ten = root.GetAttribute("ten"); m_diachi = root.GetAttribute("diachi"); m_dienthoai = root.GetAttribute("dienthoai"); for (int i = 0; i < root.ChildNodes.Count; ++i) { m_lstPhong.Add(PHONG.CreateObject((XmlElement)root.ChildNodes[i])); } }