public static bool LoadTableFromPath(string path, out TableData tableData)
{
tableData = new TableData();
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlElement root = doc.DocumentElement;
if (root.Name == "table_data_PasswordAnalyserData")
{
XmlNodeList nodes = root.ChildNodes;
tableData.description = nodes[0].InnerText;
tableData.words = new string[100];
XmlNode array = nodes[1];
for (int i = 0; i < 100; i++)
{
tableData.words[i] = array.ChildNodes[i].InnerText;
}
}
else
{
PasswordAnalyserFront.state = PasswordAnalyserFront.ConnectState.Inner;
return false;
}
PasswordAnalyserFront.state = PasswordAnalyserFront.ConnectState.Inner;
return true;
}
public static void SaveTableFromPath(string path, TableData tableData)
{
XmlDocument doc = new XmlDocument();
XmlDeclaration declar = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.AppendChild(declar);
XmlElement root = doc.CreateElement("table_data_PasswordAnalyserData");
doc.AppendChild(root);
XmlElement desc = doc.CreateElement("description");
XmlText descText = doc.CreateTextNode(tableData.description);
desc.AppendChild(descText);
root.AppendChild(desc);
XmlElement array = doc.CreateElement("array_words");
for (int i = 0; i < 100; i++)
{
XmlElement item = doc.CreateElement("item");
XmlAttribute attr = doc.CreateAttribute("number");
XmlText attrText = doc.CreateTextNode(i.ToString());
attr.AppendChild(attrText);
item.Attributes.Append(attr);
XmlText itemText = doc.CreateTextNode(tableData.words[i]);
item.AppendChild(itemText);
array.AppendChild(item);
}
root.AppendChild(array);
doc.Save(path);
}