XDocument:
Using System.XML.Linq;
XDocument xdoc = XDocument.Load (Application.dataPath + @"/myx.xml");XElement root = xdoc.Root;foreach (var r in root.Elements()) { Debug.Log( r.Name + "," +r.Value);}
sdkfjsfdj
Using System.XML;
XmlDocument doc = new XmlDocument ();doc.Load (Application.dataPath + @"/myx.xml"); //读取xml的路径XmlNodeList nodel = doc.SelectSingleNode ("id").ChildNodes; //查询xml的节点
foreach(XmlElement xe in nodel){
//xe.GetAttribute("id"); //id节点属性的内容
if(xe.Name=="path"){ //xe.Name 为id节点下的所有节点名 Debug.Log(xe.InnerText); //节点内容 }}print (doc.OuterXml) //输出所有xml内容
//元素(Element),属性(Attribute),文本(Text)
XDocument:
momo:
C#读取XML:
Unity读取xml: