public static void SaveConsoleMessages(string filePath, List <OSCConsolePacket> list) { var document = new XmlDocument(); var rootElement = (XmlElement)document.AppendChild(document.CreateElement("root")); foreach (var consoleMessage in list) { var messageElement = rootElement.AppendChild(document.CreateElement("message")); var instanceAttribute = document.CreateAttribute("info"); instanceAttribute.InnerText = consoleMessage.Info; var typeAttribute = document.CreateAttribute("type"); typeAttribute.InnerText = consoleMessage.PacketType.ToString(); messageElement.Attributes.Append(instanceAttribute); messageElement.Attributes.Append(typeAttribute); var packetElement = document.CreateElement("packet"); packetElement.InnerText = OSCPacket.ToBase64String(consoleMessage.Packet); messageElement.AppendChild(packetElement); } document.Save(filePath); }