Exemplo n.º 1
0
    private MpeStringTable CreateStringTable(string language, FileInfo file)
    {
      MpeStringTable table = new MpeStringTable(language);
      try
      {
        XmlDocument doc = new XmlDocument();
        XmlTextReader reader = new XmlTextReader(file.FullName);
        //docencoding = reader.Encoding;
        doc.Load(reader);
        if (doc.DocumentElement == null) return table;
        string strRoot = doc.DocumentElement.Name;
        if (strRoot != "Language") return table;
        XmlNodeList list = doc.DocumentElement.SelectNodes("Section/String");
        foreach (XmlNode node in list)
        {
          table.Add(int.Parse(node.Attributes["id"].Value), node.InnerText);
        }
        reader.Close();
        return table;

        /*
        XPathDocument doc = new XPathDocument(file.FullName);
        XPathNavigator nav = doc.CreateNavigator();
        XPathNodeIterator iterator = nav.Select("/Language/Section/String");
        XPathNodeIterator i, j;
        MpeStringTable table = new MpeStringTable(language);
        while (iterator.MoveNext())
        {
          //i = iterator.Current.SelectChildren("id", "");
          //j = iterator.Current.SelectChildren("value", "");
          //if (i.MoveNext() && j.MoveNext())
          //{
            try
            {
              System.Windows.Forms.MessageBox.Show(iterator.Current.GetAttribute("Id","/Language/Section/String")+iterator.Current.Value.Trim());
              table.Add(int.Parse(iterator.Current.GetAttribute("Id","")), iterator.Current.Value.Trim());
            }
            catch (Exception ee)
            {
              MpeLog.Warn("Language=[" + language + "] " + ee.Message);
            }
          //}
        }
        return table;
         */ 
      }
      catch (Exception e)
      {
        throw new MpeParserException(e.Message);
      }
    }