XML:如何读取XML文件及其内容
1、编写具有读XML文档功能的脚本ReadXML:添加using:using System;using UnityEngine;using System.Collections;using System.Collections.Generic;using System.IO;using System.Xml;

3、编写Awake()函数如下图.xmlDoc.Load(System.IO.Directory.GetCurrentDirectory(像粜杵泳) + "/xml/Temp.xml");实现xml文档的加载,将之前建立好的Temp.xml文档加载给xmlDoc.System.IO.Directory.GetCurrentDirectory() 此语句将系统指针指向工程temp文件夹root = xmlDoc.SelectSingleNode("root");//将Temp.xml文档的节点"root"赋给root变量partNodes = root.ChildNodes;//"root"节点的子节点全部赋给partNodes.这里指的是两个"part"节点


5、xe.GetAttribute("name")可以获得xe元素的name属性值,如<part id="01" name="选项1"></part>的name属性值=选项12.xe3.Name可以获得xe3元素的名字,如<part id="01" name="选项1"></part>的Name=part