using UnityEngine;
using System.Collections;
using System.IO;
using System.Xml;
public class xml : MonoBehaviour {
XmlDocument xmlDoc = new XmlDocument ();
void Start ()
{
XmlDocument xmlDoc = new XmlDocument ();
xmlDoc.Load ("Assets/Round1.xml");
XmlNode mapNode = xmlDoc.SelectSingleNode ("map");
// map
foreach (XmlNode layerNode in mapNode.ChildNodes)
{
//tileset layer
if (layerNode.Name == "layer")
{
XmlElement layerElement = (XmlElement)layerNode;
Debug.Log (layerElement.GetAttribute ("width").ToString());
Debug.Log (layerElement.GetAttribute ("height").ToString());
//data
foreach (XmlNode dataNode in ((XmlElement)layerNode).ChildNodes)
{
//tile
foreach (XmlNode tileNode in ((XmlElement)dataNode).ChildNodes) {
XmlElement tileElement = (XmlElement)tileNode;
Debug.Log (tileElement.GetAttribute ("gid").ToString ());
}
}
}
}
}
}