网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容 知识问答

XML:如何读取XML文件及其内容

时间:2024-10-16 18:57:54

1、编写具有读XML文档功能的脚本ReadXML:添加using:using System;using UnityEngine;using System.Collections;using System.Collections.Generic;using System.IO;using System.Xml;

XML:如何读取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"节点

XML:如何读取XML文件及其内容XML:如何读取XML文件及其内容

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

© 2025 智德知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com