How to load 如何加载?

<achievement>

<uniqueid>0</uniqueid>

<referencename>My Achievement</referencename>

<goal>Solve until 10 seconds</goal>

<points>10</points>

</achievement>

 

using UnityEngine;
using System.Collections;
using System.Xml;
 public class XMLEditor :MonoBehaviour
{
    void Awake()
    {
        //Load
        TextAsset textXML = (TextAsset)Resources.Load(“myxml.xml”, typeof(TextAsset));
        XmlDocument xml = new XmlDocument();
        xml.LoadXml(textXML.text);
    }
}
TextAsset~简单…
How to read 如何读取?
using UnityEngine;
using System.Collections;
using System.Xml;
public class XMLEditor : MonoBehaviour
{
    void Awake()
    {
        //Load
        TextAsset textXML = (TextAsset)Resources.Load(“myxml.xml”, typeof(TextAsset));
        XmlDocument xml = new XmlDocument(); xml.LoadXml(textXML.text);
        //Read
        XmlNode root = xml.FirstChild;
        foreach (XmlNode node in root.ChildNodes)
        {
            if (node.FirstChild.NodeType == XmlNodeType.Text)
                Debug.Log(node.InnerText);
        }
    }
}
How to save如何保存?
using UnityEngine;
using System.Collections;
using System.Xml;
 public class XMLEditor : MonoBehaviour
{
    void Awake()
    {
        //Load
        TextAsset textXML = (TextAsset)Resources.Load(“myxml.xml”, typeof(TextAsset));
        XmlDocument xml = new XmlDocument(); xml.LoadXml(textXML.text);
        //Read
        XmlNode root = xml.FirstChild; foreach(XmlNode node in root.ChildNodes)
        {
            if (node.FirstChild.NodeType == XmlNodeType.Text) node.InnerText = “none”;
        }
        Save xml.Save(AssetDatabase.GetAssetPath(textXML));
    }
}
easy!  🙂