OpenXmlFile() public static method

public static OpenXmlFile ( String &xmlContent ) : bool
xmlContent String
return bool
示例#1
0
        public static void ImportMessages()
        {
            bool   successful      = false;
            int    count           = 0;
            int    messagesUpdated = 0;
            int    messagesAdded   = 0;
            var    document        = new XmlDocument();
            string data;

            if (FileManager.OpenXmlFile(out data))
            {
                document.LoadXml(data);
                var root = document.DocumentElement;
                if (root != null)
                {
                    var messages = root.SelectNodes("//message");
                    if (messages != null)
                    {
                        foreach (XmlNode xmlNode in messages)
                        {
                            var element = xmlNode as XmlElement;
                            if (element != null)
                            {
                                string key     = element.GetAttribute("key");
                                string message = element.InnerText;
                                int    code    = saveMessage(key, message);
                                if (code == 1)
                                {
                                    messagesUpdated++;
                                }
                                if (code == 2)
                                {
                                    messagesAdded++;
                                }
                                count++;
                                successful = true;
                            }
                        }
                    }
                }
            }
            if (successful)
            {
                LogManager.Info("Successfully imported help messages. Updated:{0} Added:{1} Total Messages:{2}", messagesUpdated, messagesAdded, count);
            }
        }