var xmlFile = XDocument.Load(@DatabaseXMLPath);
var query = from c in xmlFile.Elements("ChatMapperProject").
Elements("Conversations").
Elements("Conversation") select c;
IEnumerable<XElement> convos = query as IList<XElement> ?? query.ToList();
foreach (var conversation in convos)
var xAttribute = conversation.Attribute("ID");
if (xAttribute == null) continue;
var conversationID = xAttribute.Value;
foreach (var entry in conversation.Elements("DialogEntries").Elements("DialogEntry"))
var dialogueEntry = new DialogueEntry();
dialogueEntry.ConversationID = conversationID;
var entryID = entry.Attribute("ID");
if (entryID != null) dialogueEntry.DialogueEntryID = entryID.Value;
foreach (var field in entry.Elements("Fields").Elements("Field"))
var attribute = field.Attribute("Type");
if (attribute == null || attribute.Value != "Localization") continue;
var title = field.Element("Title");
if (title != null && title.Value == "Dialogue Text")
var text = field.Element("Value");
dialogueEntry.DefaultPhrase = text.Value;
else if (title != null && title.Value == "ru")
var text = field.Element("Value");
dialogueEntry.RuPhrase = text.Value;
EntriesToExport.Add(dialogueEntry);
"Added Entry to Export: ConversationID: {0}, EntryID: {1}, DefaultText: {2}, RuText: {3}",
dialogueEntry.ConversationID, dialogueEntry.DialogueEntryID, dialogueEntry.DefaultPhrase,