码迷,mamicode.com
首页 > 移动开发 > 详细

单独解析androidXml

时间:2016-06-24 10:46:32      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using UnityEngine.UI;
using System.IO;
using System.Text;
public class AnalyzeXMLAlone : MonoBehaviour {
public GameObject aa;
public string _result;
public string score;

void Start()
{

StartCoroutine(Load());
}
IEnumerator Load()
{
string localPath = Application.streamingAssetsPath + "/AndroidLoad.xml";
WWW www = new WWW(localPath);
while (!www.isDone)
{
Debug.Log("Getting GetXML");
yield return www;
ParseXml(www);

}
}
//解析
public void ParseXml(WWW www)
{
List<XmlNode> xmlNodeList = new List<XmlNode>();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(www.text);
XmlNodeList nodeList = xmlDoc.SelectSingleNode("Image").ChildNodes;
//遍历每一个节点,拿节点的属性以及节点的内容
foreach (XmlElement xe in nodeList)
{
foreach (XmlElement x1 in xe.ChildNodes)
{

//分割为字符串数组(Split)
string newstr = x1.InnerText;
//Debug.Log("newstr+"+newstr);
string[] arr = newstr.Split(‘|‘);
//判断文件是否存在,否则下载--成功读取图片名字
//score += arr[1];
// aa.text = "分数是:" + score;
aa.GetComponent<Text>().text = "分数是:" + arr[1];
xmlNodeList.Add(x1);

}

}
//xmlDoc.Save(filepath);

}
void OnGUI()
{
GUIStyle titleStyle = new GUIStyle();
titleStyle.fontSize = 20;
titleStyle.normal.textColor = new Color(46f / 256f, 163f / 256f, 256f / 256f, 256f / 256f);
GUI.Label(new Rect(400, 10, 500, 200), _result, titleStyle);
}
}

单独解析androidXml

标签:

原文地址:http://www.cnblogs.com/ZeroMurder/p/5613294.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!