コード例 #1
0
ファイル: AnalyseXML.cs プロジェクト: zhangbo27/bbsmax
        /// <summary>
        /// ����XML���������ļ���
        /// </summary>
        static List <Model_XML> AnalyseXML(Stream stream)
        {
            int         total = 0; //XML����
            XmlDocument doc   = new XmlDocument();

            //doc.Load(EmoticonManager.userRootPath + "Face.xml");
            doc.Load(stream);
            stream.Close();
            stream.Dispose();


            XmlNode defaultNode = doc.SelectSingleNode("//CUSTOMFACE");

            if (defaultNode != null)
            {
                total += int.Parse(defaultNode.Attributes["count"].Value);
            }

            XmlNodeList GROUPnodeList = doc.SelectNodes("//CUSTOMFACEGROUP");

            if (GROUPnodeList != null)
            {
                foreach (XmlNode childNode in GROUPnodeList)
                {
                    total += int.Parse(childNode.Attributes["count"].Value);
                }
            }

            List <Model_XML> XMLList = new List <Model_XML>(total);
            Model_XML        tempModel;

            //Ĭ�Ͻڵ�
            string FolderName = "�������";

            //Directory.CreateDirectory(_path + "/" + FolderName);
            if (defaultNode != null)
            {
                foreach (XmlElement childNode in defaultNode)
                {
                    tempModel            = new Model_XML();
                    tempModel.File_ORG   = childNode.SelectSingleNode("FILE-ORG").InnerText;
                    tempModel.File_FIXED = childNode.SelectSingleNode("FILE-FIXED").InnerText;
                    tempModel.Id         = childNode.Attributes["id"].Value;
                    tempModel.Tip        = childNode.Attributes["tip"].Value;
                    tempModel.Multiframe = childNode.Attributes["multiframe"].Value;
                    tempModel.Shortcut   = childNode.Attributes["shortcut"].Value;
                    tempModel.FileIndex  = int.Parse(childNode.Attributes["FileIndex"].Value);
                    tempModel.Folder     = FolderName;
                    XMLList.Add(tempModel);
                }
            }

            if (GROUPnodeList != null)
            {
                //��ڵ�
                foreach (XmlNode node in GROUPnodeList)
                {
                    string GroupFolderName = ((XmlElement)node).Attributes["name"].Value;
                    //�õ���ǰ�ڵ��µ������ӽ��
                    //Directory.CreateDirectory(_path + "/" + GroupFolderName);
                    XmlNodeList childNodeList = node.ChildNodes;
                    foreach (XmlNode childNode in childNodeList)
                    {
                        tempModel            = new Model_XML();
                        tempModel.File_ORG   = childNode.SelectSingleNode("FILE-ORG").InnerText;
                        tempModel.File_FIXED = childNode.SelectSingleNode("FILE-FIXED").InnerText;
                        tempModel.Id         = ((XmlElement)childNode).Attributes["id"].Value;
                        tempModel.Tip        = ((XmlElement)childNode).Attributes["tip"].Value;
                        tempModel.Multiframe = ((XmlElement)childNode).Attributes["multiframe"].Value;
                        tempModel.FileIndex  = int.Parse(((XmlElement)childNode).Attributes["FileIndex"].Value);
                        tempModel.Folder     = GroupFolderName;
                        XMLList.Add(tempModel);
                    }
                }
            }
            //File.Delete(_path + "/Face.xml");
            //File.Delete(EmoticonManager.userRootPath + "Face.xml");
            return(XMLList);
        }
コード例 #2
0
ファイル: AnalyseXML.cs プロジェクト: huchao007/bbsmax
        /// <summary>
        /// ����XML���������ļ���
        /// </summary>
        static List<Model_XML> AnalyseXML(Stream stream)
        {
            int total = 0;     //XML����
            XmlDocument doc = new XmlDocument();
            //doc.Load(EmoticonManager.userRootPath + "Face.xml");
            doc.Load(stream);
            stream.Close();
            stream.Dispose();
            

            XmlNode defaultNode = doc.SelectSingleNode("//CUSTOMFACE");
            if (defaultNode!=null)
                total += int.Parse(defaultNode.Attributes["count"].Value);

            XmlNodeList GROUPnodeList = doc.SelectNodes("//CUSTOMFACEGROUP");
            if (GROUPnodeList != null)
            {
                foreach (XmlNode childNode in GROUPnodeList)
                    total += int.Parse(childNode.Attributes["count"].Value);
            }

            List<Model_XML> XMLList = new List<Model_XML>(total);
            Model_XML tempModel;

            //Ĭ�Ͻڵ�
            string FolderName = "�������";
            //Directory.CreateDirectory(_path + "/" + FolderName);
            if (defaultNode != null)
            {
                foreach (XmlElement childNode in defaultNode)
                {
                    tempModel = new Model_XML();
                    tempModel.File_ORG = childNode.SelectSingleNode("FILE-ORG").InnerText;
                    tempModel.File_FIXED = childNode.SelectSingleNode("FILE-FIXED").InnerText;
                    tempModel.Id = childNode.Attributes["id"].Value;
                    tempModel.Tip = childNode.Attributes["tip"].Value;
                    tempModel.Multiframe = childNode.Attributes["multiframe"].Value;
                    tempModel.Shortcut = childNode.Attributes["shortcut"].Value;
                    tempModel.FileIndex = int.Parse(childNode.Attributes["FileIndex"].Value);
                    tempModel.Folder = FolderName;
                    XMLList.Add(tempModel);
                }
            }

            if (GROUPnodeList != null)
            {
                //��ڵ�
                foreach (XmlNode node in GROUPnodeList)
                {
                    string GroupFolderName = ((XmlElement)node).Attributes["name"].Value;
                    //�õ���ǰ�ڵ��µ������ӽ��
                    //Directory.CreateDirectory(_path + "/" + GroupFolderName);
                    XmlNodeList childNodeList = node.ChildNodes;
                    foreach (XmlNode childNode in childNodeList)
                    {
                        tempModel = new Model_XML();
                        tempModel.File_ORG = childNode.SelectSingleNode("FILE-ORG").InnerText;
                        tempModel.File_FIXED = childNode.SelectSingleNode("FILE-FIXED").InnerText;
                        tempModel.Id = ((XmlElement)childNode).Attributes["id"].Value;
                        tempModel.Tip = ((XmlElement)childNode).Attributes["tip"].Value;
                        tempModel.Multiframe = ((XmlElement)childNode).Attributes["multiframe"].Value;
                        tempModel.FileIndex = int.Parse(((XmlElement)childNode).Attributes["FileIndex"].Value);
                        tempModel.Folder = GroupFolderName;
                        XMLList.Add(tempModel);
                    }
                }
            }
            //File.Delete(_path + "/Face.xml");
            //File.Delete(EmoticonManager.userRootPath + "Face.xml");
            return XMLList;
        }