public void SetCatalogueEntry(CatalogueEntry e) { if (RootElement == null) { RootElement = OpenedDocument.CreateElement("Catalogue"); } if (e.ID > HighestID) { HighestID = e.ID; } if (RootElement.ChildNodes.Count > 0) { XmlNodeList Elements = RootElement.ChildNodes; foreach (XmlNode n in Elements) { if (GetIDAttribute(n).Equals(e.ID.ToString())) { XmlElement t = (XmlElement)n; t.InnerText = e.Title; t.SetAttribute("Works", e.Works.ToString()); t.SetAttribute("PageNo", e.PageNo.ToString()); return; } } } RootElement.AppendChild(OpenedDocument.ImportNode(e.ToXml().ChildNodes[0], true)); }
public void DeleteCatalogueEntry(CatalogueEntry e) { XmlNodeList Elements = RootElement.ChildNodes; foreach (XmlNode n in Elements) { if (GetIDAttribute(n).Equals(e.ID.ToString())) { RootElement.RemoveChild(n); return; } } }