前端之家收集整理的这篇文章主要介绍了
读取XML方法,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using NTFrame;
using System.Security;
public class WorldMusicCtrl : SingletonMono<WorldMusicCtrl> {
public Dictionary<string,WorldMusicData> mDatasLists = new Dictionary<string,WorldMusicData>();
public void InitData(string xmlText)
{
mDatasLists.Clear();
SecurityElement xmlNodes = ClientTools.GetXmlListFromFile(xmlText);
foreach (SecurityElement dancer in xmlNodes.Children)
{
if (dancer.Tag == "Data")
{
string id = dancer.Attribute("Id");
string rects = dancer.Attribute("Rects");
string musicName = dancer.Attribute("MusicName");
// WorldMusicData data = new WorldMusicData();
// data.Init(id,musicName,rects);
// mDatasLists[data.mId] = data;
}
}
}
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;
using System;
using CommonEnum;
using Mono.Xml;
public class ClientTools
{
public static System.Security.SecurityElement GetXmlListFromFile(string text)
{
SecurityParser SP = new SecurityParser();
SP.LoadXml(text);
return SP.ToXml();
}
}