public static void ParseConfigXml() { //XmlUtility.Begin(protocolXmlAssetPath); string xmlContent = File.ReadAllText(EditorUtils.AssetPath2FilePath(ExportProtocolConstant.ProtocolConfigAssetPath)); XMLNode rootNode = XMLParser.Parse(xmlContent); /*XMLNodeList enumNodes = rootNode.GetNodeList("protocol>0>enum_type>0>type"); * foreach (XMLNode enumNode in enumNodes) * { * ExportEnumType(enumNode); * }*/ XMLNodeList classNodes = rootNode.GetNodeList("protocol>0>custom_type>0>type"); foreach (XMLNode classNode in classNodes) { ExportClassType(classNode); } return; XMLNodeList sectionNodes = rootNode.GetNodeList("protocol>0>section"); foreach (XMLNode sectionNode in sectionNodes) { ExportSectionMsg(sectionNode); } }
// fill a multilanguages object from languages detected from an XMLNode public static void FillLanguages(MultiLanguages multiLang, XMLNode node) { XMLNodeList names = node.GetNodeList ("nom>0>text"); foreach (XMLNode name in names) { string lang = name.GetValue ("@lang"); string text = name.GetValue ("_text"); string defaultAtt = name.GetValue ("@defaut"); bool isDefault; bool.TryParse (defaultAtt, out isDefault); multiLang.AddText (lang, text, isDefault); } XMLNodeList parent = node.GetNodeList ("parent>0>text"); foreach (XMLNode name in parent) { string lang = name.GetValue ("@lang"); string text = name.GetValue ("_text"); string defaultAtt = name.GetValue ("@defaut"); bool isDefault; bool.TryParse (defaultAtt, out isDefault); //Debug.Log (text); multiLang.AddText (lang + "_parent", text, isDefault); } }
public string GetComment(int rowIndex, int columnIndex) { string commentFile = "xl/comments" + Index + ".xml"; XMLNode commentRootNode = this.m_Excel.m_Archive.GetXmlNode(commentFile); if (commentRootNode == null) { return(null); } //default value int columnName = columnIndex + m_ColumnStart; int rowName = rowIndex + 1; if (this.Rows != null && this.Rows.Count > rowIndex) { Row row = this.Rows[rowIndex]; rowName = row.RowIndex; } string commentCeilName = Cell.GetExcelColumnName(columnName) + rowName; XMLNodeList commentList = commentRootNode.GetNodeList("comments>0>commentList>0>comment"); if (commentList != null && commentList.Count > 0) { foreach (XMLNode commentNode in commentList) { if (commentNode.GetValue("@ref") == commentCeilName) { return(commentNode.GetValue("text>0>r>1>t>0>_text")); } } } return(null); }
internal SharedStrings(ZipArchive archive) { this.m_SharedStringsExist = true; this.m_StringArray = new List <string> (); XMLNode document = archive.GetXmlNode("xl/sharedStrings.xml"); if (document == null) { this.m_SharedStringsExist = false; return; } //List<XMLNode> nodeList = new List<XMLNode> (); //only one share string in one si!!! XMLNodeList siNodeList = document.GetNodeList("sst>0>si"); foreach (XMLNode node in siNodeList) { XMLNodeList tList = node.GetDeepNodeList("t"); //handle for <t xml:space="preserve"> </t> string tValue = string.Empty; foreach (var tNode in tList) { tValue += tNode.GetValue("_text"); } this.m_StringArray.Add(tValue); } }
/// <summary> /// 设置反外挂信息 /// </summary> /// <param name="rootnode"></param> static void SetAccInfo(XMLNode rootnode) { if (rootnode == null) { LogSystem.LogWarning("SetAccInfo is null"); return; } XMLNodeList xmlNodeList = rootnode.GetNodeList("Resources>0>Acc>0>Property"); if (xmlNodeList == null) { LogSystem.LogWarning("SetAccInfo is null"); return; } foreach (XMLNode n in xmlNodeList) { string strID = n.GetValue("@No"); if (accInfo.ContainsKey(strID)) { accInfo[strID].Add(n.GetValue("@Name")); } else { List <string> info = new List <string>(); info.Add(n.GetValue("@Name")); accInfo.Add(strID, info); } } }
private Worksheet[] GetWorksheetProperties() { PrepareArchive(); var worksheets = new List <Worksheet>(); string xmlText = this.Archive.GetXmlText("xl/workbook.xml"); XMLNode document = XMLParser.Parse(xmlText); if (document == null) { throw new Exception("Unable to load workbook.xml"); } XMLNodeList nodeList = document.GetNodeList("workbook>0>sheets>0>sheet"); foreach (XMLNode node in nodeList) { var worksheet = new Worksheet(this); worksheet.Index = int.Parse(node.GetValue("@sheetId")); worksheet.Name = node.GetValue("@name"); worksheets.Add(worksheet); } return(worksheets.ToArray()); }
public XMLNodeList GetVideoList(string value) { XMLNode scene = GetScene(value); XMLNodeList videos = scene.GetNodeList("videos>0>video"); return(videos); }
// 读取XML void ReadXML() { m_enemylist = new ArrayList(); XMLParser xmlparse = new XMLParser(); XMLNode node = xmlparse.Parse(xmldata.text); XMLNodeList list = node.GetNodeList("ROOT>0>table"); for (int i = 0; i < list.Count; i++) { string wave = node.GetValue("ROOT>0>table>" + i + ">@wave"); string enemyname = node.GetValue("ROOT>0>table>" + i + ">@enemyname"); string level = node.GetValue("ROOT>0>table>" + i + ">@level"); string wait = node.GetValue("ROOT>0>table>" + i + ">@wait"); SpawnData data = new SpawnData(); data.wave = int.Parse(wave); data.enemyname = enemyname; data.level = int.Parse(level); data.wait = float.Parse(wait); m_enemylist.Add(data); } }
public XMLNodeList GetPdfList(string value) { XMLNode scene = GetScene(value); XMLNodeList pdfs = scene.GetNodeList("pdfs>0>pdf"); return(pdfs); }
public override void ParseNode(XMLNode node) { foreach (XMLNode conditionNode in node.GetNodeList(StoryConst.CONDITION_NAME)) { this.TaskId = conditionNode.GetValue("@value"); } }
public override void ParseNode(XMLNode node) { base.ParseNode(node); foreach (XMLNode conditionNode in node.GetNodeList(StoryConst.CONDITION_NAME)) { string comparator = conditionNode.GetValue("@comparator"); string value = conditionNode.GetValue("@value"); string roleType = conditionNode.GetValue("@roleType"); string id = conditionNode.GetValue("@id"); if (null != comparator) { this.hpComparator = comparator; } if (null != value) { this.hpValue = value; } if (null != roleType) { this.RoleType = roleType; } if (null != id) { this.Id = id; } } }
public static void SetUpdaterAddress(TextAsset text) { if (text == null) { return; } XMLParser xMLParser = new XMLParser(); XMLNode xMLNode = xMLParser.Parse(text.text); XMLNodeList nodeList = xMLNode.GetNodeList("Addresses>0>Address"); if (nodeList != null) { foreach (XMLNode xMLNode2 in nodeList) { Config.GameAddress gameAddress = new Config.GameAddress(); gameAddress.strID = xMLNode2.GetValue("@ID"); gameAddress.strName = xMLNode2.GetValue("@Name"); gameAddress.strDomainAddress = xMLNode2.GetValue("@DomainAddr") + "/" + Config.GetInstallationVersion(); gameAddress.strIPAddress = xMLNode2.GetValue("@IPAddr") + "/" + Config.GetInstallationVersion(); if (!Config.mUpdaterAddress.ContainsKey(gameAddress.strID)) { Config.mUpdaterAddress.Add(gameAddress.strID, gameAddress); } } } }
public static void SetPushServerList(string xmlString) { int startIndex = xmlString.IndexOf('<'); xmlString = xmlString.Substring(startIndex); xmlString.Trim(); XMLParser xMLParser = new XMLParser(); XMLNode xMLNode = xMLParser.Parse(xmlString); XMLNodeList xMLNodeList = (XMLNodeList)xMLNode["PushServers"]; if (xMLNodeList == null) { return; } for (int i = 0; i < xMLNodeList.Count; i++) { XMLNode xMLNode2 = xMLNodeList[i] as XMLNode; XMLNodeList nodeList = xMLNode2.GetNodeList("Server"); if (nodeList != null) { for (int j = 0; j < nodeList.Count; j++) { XMLNode xMLNode3 = nodeList[j] as XMLNode; Config.PushServerInfo pushServerInfo = new Config.PushServerInfo(); foreach (DictionaryEntry dictionaryEntry in xMLNode3) { if (dictionaryEntry.Value != null) { string text = dictionaryEntry.Key as string; if (text[0] == '@') { text = text.Substring(1); if (text == "ID") { pushServerInfo.strServerID = (dictionaryEntry.Value as string); } else if (text == "Name") { pushServerInfo.strServerName = (dictionaryEntry.Value as string); } else if (text == "IP") { pushServerInfo.strServerIP = (dictionaryEntry.Value as string); } else if (text == "Port") { pushServerInfo.strServerPort = (dictionaryEntry.Value as string); } else if (text == "ApiKey") { pushServerInfo.strApiKey = (dictionaryEntry.Value as string); } } } } Config.mDictPushServerList.Add(pushServerInfo); } } } }
private static void SetAccInfo(XMLNode rootnode) { if (rootnode == null) { LogSystem.LogWarning(new object[] { "SetAccInfo is null" }); return; } XMLNodeList nodeList = rootnode.GetNodeList("Resources>0>Acc>0>Property"); if (nodeList == null) { LogSystem.LogWarning(new object[] { "SetAccInfo is null" }); return; } foreach (XMLNode xMLNode in nodeList) { string value = xMLNode.GetValue("@No"); if (Config.accInfo.ContainsKey(value)) { Config.accInfo[value].Add(xMLNode.GetValue("@Name")); } else { List <string> list = new List <string>(); list.Add(xMLNode.GetValue("@Name")); Config.accInfo.Add(value, list); } } }
//剧情脚本模板加载回调 private void ScriptTemplateLoaded(TextAsset textObj) { if (null == textObj) { return; } string triggerName = "triggerTable>0>trigger"; XMLNode rootNode = XMLParser.Parse(textObj.ToString()); foreach (XMLNode triggerNode in rootNode.GetNodeList(triggerName)) { string scriptName = triggerNode.GetValue("@scriptName"); string type = triggerNode.GetValue("@type"); ScriptBaseEntry baseEntry = StoryFactory.GetEntry(type); if (null != baseEntry) { baseEntry.ScriptName = scriptName; baseEntry.ParseNode(triggerNode); scriptEntryList.Add(baseEntry); } } }
public void Awake() { XMLNode xml = XMLParser.Parse((Resources.Load("level", typeof(TextAsset)) as TextAsset).text); XMLNodeList tilesXML = xml.GetNodeList("doc>0>tiles>0>tile"); for (int i = 0; i < tilesXML.Count; i++) { XMLNode tileXML = tilesXML[i] as XMLNode; Tile tile = new Tile(); tile.type = tileXML.GetValue("@type"); XMLNodeList enemiesXML = tileXML.GetNodeList("enemies>0>enemy"); for (int j = 0; j < enemiesXML.Count; j++) { XMLNode enemyXML = enemiesXML[j] as XMLNode; Enemy enemy = new Enemy(); enemy.type = enemyXML.GetValue("@type"); enemy.position = new Vector3( float.Parse(enemyXML.GetValue("@x")), 0, float.Parse(enemyXML.GetValue("@z")) ); tile.enemies.Add(enemy); } tiles.Add(tile); } }
private void loadModuleTip() { //TextAsset tepXML = (TextAsset)ResMgr.instance.load("xml/module"); //XmlDocument doc = InitConfig.loadXMLByContent(tepXML.ToString()); //XmlNodeList busNodeList = doc.SelectSingleNode("i18n/businessTip").ChildNodes; //XmlNodeList uiNodeList = doc.SelectSingleNode("i18n/uiTip").ChildNodes; //parserMsgList(moduleDict, busNodeList); //parserMsgList(moduleDict, uiNodeList); TextAsset tepXML = (TextAsset)ResMgr.instance.load("xml/module"); XMLNode rootNode = XMLParser.Parse(tepXML.ToString()); XMLNodeList busNodeList = rootNode.GetNodeList("i18n>0>businessTip>0>tip"); XMLNodeList uiNodeList = rootNode.GetNodeList("i18n>0>uiTip>0>tip"); //Debug.Log("busNodeList.len:" + busNodeList.Count + ",uiNodeList.len:" + uiNodeList.Count); parserMsgList(moduleDict, busNodeList); parserMsgList(moduleDict, uiNodeList); }
public void Awake() { xml = XMLParser.Parse((Resources.Load("data", typeof(TextAsset)) as TextAsset).text); wavesXML = xml.GetNodeList("doc>0>waves>0>wave"); enemiesXML = xml.GetNodeList("doc>0>units>0>enemies>0>enemy"); heroes = new List <Hero>(); enemies = new List <Enemy>(); wave = 0; numberOfWaves = 20; playerGold = 1000; playerLives = 20; numberOfHeroes = 0; maxHeroes = 12; CustomCursor c = Instantiate(Resources.Load(("CustomCursor"), typeof(CustomCursor)) as CustomCursor) as CustomCursor; }
public Row(XMLNode rowElement, SharedStrings sharedStrings) { try { this.RowNumber = int.Parse(rowElement.GetValue("@r")); } catch (Exception ex) { throw new Exception("Row Number not found", ex); } XMLNodeList cellList = rowElement.GetNodeList("c"); if (cellList != null && cellList.Count > 0) { this.Cells = GetCells(rowElement.GetNodeList("c"), sharedStrings); } }
bool loadAtlases(ref XMLNode nodes) { XMLNodeList nodeList = nodes.GetNodeList("retinaProData>0>ArrayOfRetinaProAtlas>0>retinaProAtlas"); if (nodeList == null) { return(false); } foreach (XMLNode node in nodeList) { retinaProRuntimeAtlas ra = new retinaProRuntimeAtlas(); foreach (DictionaryEntry pair in node) { if (pair.Key.ToString().CompareTo("name") == 0) { XMLNodeList vs = (XMLNodeList)pair.Value; foreach (XMLNode v in vs) { foreach (DictionaryEntry dp in v) { if (dp.Key.ToString().CompareTo("_text") == 0) { ra.name = dp.Value.ToString(); } } } } else if (pair.Key.ToString().CompareTo("isFont") == 0) { XMLNodeList vs = (XMLNodeList)pair.Value; foreach (XMLNode v in vs) { foreach (DictionaryEntry dp in v) { if (dp.Key.ToString().CompareTo("_text") == 0) { string str = dp.Value.ToString(); Boolean.TryParse(str, out ra.isFont); } } } } } // add one to the atlas list atlasList.Add(ra); #if RETINAPRO_DEBUGLOG Debug.Log("RetinaPro Atlas = " + ra.name + ", " + "isFont = " + ra.isFont); #endif } return(true); }
public XMLNode GetChildNode(XMLNode target, string value) { XMLNodeList list = target.GetNodeList(value); if (list == null) { return(null); } return(list[0] as XMLNode); }
/// <summary> /// 游戏配置信息 /// </summary> /// <param name="xmlNodeList"></param> static void SetCustomInfo(XMLNodeList xmlNodeList) { if (xmlNodeList == null) { LogSystem.LogWarning("SetCustomInfo is null"); return; } ///解析首段中的类型定义 for (int i = 0; i < xmlNodeList.Count; i++) { XMLNode xmlnode = xmlNodeList[i] as XMLNode; XMLNodeList childNodeList1 = xmlnode.GetNodeList("Resource"); if (childNodeList1 != null) { for (int j = 0; j < childNodeList1.Count; j++) { XMLNode childnode = childNodeList1[j] as XMLNode; CustomInfo psInfo = new CustomInfo(); foreach (System.Collections.DictionaryEntry objDE in childnode) { if (objDE.Value == null) { continue; } string strKey = objDE.Key as string; if (strKey[0] != '@') { continue; } strKey = strKey.Substring(1); if (strKey == "ID") { psInfo.strCustomInfoID = objDE.Value as string; } else if (strKey == "Value") { psInfo.strCustomInfoVaule = objDE.Value as string; } } if (mDictCustomInfoList.ContainsKey(psInfo.strCustomInfoID)) { mDictCustomInfoList[psInfo.strCustomInfoID] = psInfo; } else { mDictCustomInfoList.Add(psInfo.strCustomInfoID, psInfo); } } } } }
private static void SetChannelInfo(XMLNode rootnode) { if (rootnode == null) { return; } XMLNodeList nodeList = rootnode.GetNodeList("Resources>0>Channel>0>Property"); Config.GameArea = Config.EnumArea.None; LogSystem.LogWarning(new object[] { "----------strChannelUniqueName--------" + Config.strChannelUniqueName }); if (string.IsNullOrEmpty(Config.strChannelUniqueName)) { Config.strChannelUniqueName = "android_snail"; } foreach (XMLNode xMLNode in nodeList) { string value = xMLNode.GetValue("@ID"); if (value == Config.strChannelUniqueName) { Config.payCallBackURL = xMLNode.GetValue("@PayCallBackUrl"); Config.ClientInstallUrl = xMLNode.GetValue("@ClientInstallUrl"); Config.strNoticeName = xMLNode.GetValue("@NoticeName"); Config.strChannelName = xMLNode.GetValue("@ChannelName"); Config.bNeedDataCollect = "1".Equals(xMLNode.GetValue("@DataCollect")); LogSystem.LogWarning(new object[] { "------2----bNeedDataCollect--------" + Config.bNeedDataCollect }); LogSystem.LogWarning(new object[] { "------2-----strID-------" + value }); string value2 = xMLNode.GetValue("@Area"); int gameArea; if (!string.IsNullOrEmpty(value2) && int.TryParse(value2, out gameArea)) { Config.GameArea = (Config.EnumArea)gameArea; } return; } } LogSystem.LogWarning(new object[] { "channelName not have info ", Config.strChannelUniqueName }); LogSystem.LogWarning(new object[] { "----1--------bNeedDataCollect------" + Config.bNeedDataCollect }); }
/// <summary> /// 设置所有服务器信息 /// </summary> /// <param name="text">服务器列表文本</param> public static void SetAllServerList(string xmlString) { int index = xmlString.IndexOf('<'); xmlString = xmlString.Substring(index); xmlString.Trim(); XMLParser parse = new XMLParser(); XMLNode rootnode = parse.Parse(xmlString); XMLNodeList xmlNodeList = (XMLNodeList)rootnode["Servers"]; if (xmlNodeList == null) { return; } ///解析首段中的类型定义 for (int i = 0; i < xmlNodeList.Count; i++) { XMLNode xmlnode = xmlNodeList[i] as XMLNode; XMLNodeList childNodeList = xmlnode.GetNodeList("Server"); if (childNodeList != null) { for (int j = 0; j < childNodeList.Count; j++) { XMLNode childnode = childNodeList[j] as XMLNode; Dictionary <string, string> server = new Dictionary <string, string>(); foreach (System.Collections.DictionaryEntry objDE in childnode) { if (objDE.Value == null) { continue; } string strKey = objDE.Key as string; if (strKey[0] != '@') { continue; } strKey = strKey.Substring(1); if (!server.ContainsKey(strKey)) { server.Add(strKey, (string)objDE.Value); } else { server[strKey] = (string)objDE.Value; } } mDictAllServerList.Add(server); } } } }
public override void ParseNode(XMLNode node) { base.ParseNode(node); foreach (XMLNode conditionNode in node.GetNodeList(StoryConst.CONDITION_NAME)) { this.value = conditionNode.GetValue("@value"); } ParseCoordinate(); }
public static XMLNodeList GetConfigDataXml(string xmlPath) { string xmlContent = File.ReadAllText(xmlPath); XMLNode rootNode = XMLParser.Parse(xmlContent); if (rootNode != null) { return(rootNode.GetNodeList("items>0>config>0>item")); } return(null); }
public void Read() { string fileNameInZip = string.Format("xl/worksheets/sheet{0}.xml", Index); XMLNode document = m_Excel.m_Archive.GetXmlNode(fileNameInZip); if (document != null) { XMLNodeList rowList = document.GetNodeList("worksheet>0>sheetData>0>row"); Rows = GetRows(rowList); this.RowCount = Rows.Count; } }
//剧情加载回调 private void ScriptLoaded(TextAsset textObj) { try { if (!scriptDict.ContainsKey(curScriptEntry.ScriptName)) { if (null != textObj) { scriptDict.Add(curScriptEntry.ScriptName, textObj); } } //判断文件是否存在 if (!scriptDict.ContainsKey(curScriptEntry.ScriptName)) { return; } if (null != AppMap.Instance.me.Controller.GoName) { roleGoActive = AppMap.Instance.me.Controller.GoName.activeSelf; } //解析剧情数据 string actionName = "script>0>action"; XMLNode rootNode = XMLParser.Parse(scriptDict[curScriptEntry.ScriptName].ToString()); if (null != rootNode) { foreach (XMLNode actionNode in rootNode.GetNodeList(actionName)) { string type = actionNode.GetValue("@type"); BaseAction baseAction = StoryFactory.GetAction(type); if (null != baseAction) { baseAction.ParseNode(actionNode); actionList.Add(baseAction); } } } } finally { loadingData = false; if (null != loadActionDataCallback) { loadActionDataCallback(); } } }
/// <summary> /// 设置渠道信息 /// </summary> /// <param name="xmlNodeList"></param> static void SetChannelInfo(XMLNode rootnode) { if (rootnode == null) { return; } XMLNodeList xmlNodeList = rootnode.GetNodeList("Resources>0>Channel>0>Property"); GameArea = EnumArea.None; if (string.IsNullOrEmpty(strChannelUniqueName)) { #if UNITY_IPHONE strChannelUniqueName = "appstore"; #else strChannelUniqueName = "android_snail"; #endif } ///解析首段中的类型定义 foreach (XMLNode n in xmlNodeList) { string strID = n.GetValue("@ID"); if (strID == strChannelUniqueName) { payCallBackURL = n.GetValue("@PayCallBackUrl"); ClientInstallUrl = n.GetValue("@ClientInstallUrl"); strNoticeName = n.GetValue("@NoticeName"); strChannelName = n.GetValue("@ChannelName"); mOrderType = StaticUtilTools.IntParse(n.GetValue("@OrderType")); //采集 bNeedDataCollect = "1".Equals(n.GetValue("@DataCollect")); #if UNITY_STANDALONE_OSX && !UNITY_EDITOR bNeedDataCollect = true; #endif //地区 string strArea = n.GetValue("@Area"); if (!string.IsNullOrEmpty(strArea)) { int iArea; if (int.TryParse(strArea, out iArea)) { GameArea = (EnumArea)iArea; } } return; } } LogSystem.LogWarning("channelName not have info ", strChannelUniqueName); }
private static void SetCustomInfo(XMLNodeList xmlNodeList) { if (xmlNodeList == null) { LogSystem.LogWarning(new object[] { "SetCustomInfo is null" }); return; } for (int i = 0; i < xmlNodeList.Count; i++) { XMLNode xMLNode = xmlNodeList[i] as XMLNode; XMLNodeList nodeList = xMLNode.GetNodeList("Resource"); if (nodeList != null) { for (int j = 0; j < nodeList.Count; j++) { XMLNode xMLNode2 = nodeList[j] as XMLNode; Config.CustomInfo customInfo = new Config.CustomInfo(); foreach (DictionaryEntry dictionaryEntry in xMLNode2) { if (dictionaryEntry.Value != null) { string text = dictionaryEntry.Key as string; if (text[0] == '@') { text = text.Substring(1); if (text == "ID") { customInfo.strCustomInfoID = (dictionaryEntry.Value as string); } else if (text == "Value") { customInfo.strCustomInfoVaule = (dictionaryEntry.Value as string); } } } } if (Config.mDictCustomInfoList.ContainsKey(customInfo.strCustomInfoID)) { Config.mDictCustomInfoList[customInfo.strCustomInfoID] = customInfo; } else { Config.mDictCustomInfoList.Add(customInfo.strCustomInfoID, customInfo); } } } } }
public override void ParseNode(XMLNode node) { base.ParseNode(node); foreach (XMLNode conditionNode in node.GetNodeList(StoryConst.CONDITION_NAME)) { string monsterId = conditionNode.GetValue("@monsterId"); if (null != monsterId) { this.MonsterId = monsterId; } } }