1、<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<toy id="0" colorid="0" rawdataname="tuoyuan" />
<toy id="4" colorid="4" rawdataname="changfangxing" />
</ROOT>
二、加载方式
1、
XmlDocument xmldoc = new XmlDocument();
TextAsset toydata = (TextAsset)Resources.Load("XML/mytoy");
xmldoc.LoadXml(toydata.text.ToString().Trim());
//读取方式一 XmlNode root = xmldoc.SelectSingleNode("ROOT"); if (root != null) { XmlNodeList nodelist = root.ChildNodes; foreach (XmlNode node in nodelist) { XmlElement xmlelement = (XmlElement)node; int id = int.Parse(xmlelement.GetAttribute("id")); int colorid = int.Parse(xmlelement.GetAttribute("colorid")); string rawdataname = xmlelement.GetAttribute("rawdataname"); } }
原文地址:https://www.jb51.cc/xml/298988.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。