Beispiel #1
0
    private static void ParseXml(string path, string xmlBinExportDir)
    {
        try
        {
            var complieXml = new CompileXml();
            var xmlDoc     = new XmlDocument();
            xmlDoc.Load(path);
            var rootNode = xmlDoc.SelectSingleNode("root");

            var nodeList = rootNode.SelectSingleNode("Props").ChildNodes;
            foreach (var childNode in nodeList)
            {
                var childElement = (XmlElement)childNode;
                var fieldName    = childElement.InnerText;

                CsBuilder.IsPrimaryKey(ref fieldName);
                var fieldType = CsBuilder.GetFieldType(ref fieldName);

                complieXml.m_FieldNameList.Add(fieldName);
                complieXml.m_FieldNameBufferToIndexMap.Add(fieldName, complieXml.m_FieldNameBufferToIndexMap.Count);
                complieXml.m_FieldTypeList.Add(TypeMap[fieldType]);
            }

            complieXml.m_FieldNameBufferSzie = GetStringBufferSize(complieXml.m_FieldNameList);
            complieXml.m_FieldCount          = (short)complieXml.m_FieldTypeList.Count;

            string name = Path.GetFileNameWithoutExtension(path);

            FileStream fs = File.Create(xmlBinExportDir + "/" + name + ".xml");

            complieXml.WriteHead(fs);

            GetStringBuffer(complieXml, rootNode);
            complieXml.WriteStringBuffer(fs);

            WriteItems(fs, complieXml, rootNode);

            fs.Flush();
            fs.Close();
        }
        catch (Exception e)
        {
            Debug.LogError(e);
        }
    }