import System.Xml;
import System.IO;
var filename = "Assets/sample.xml";
function Start () {
print("processing xml");
var reader:XmlTextReader = new XmlTextReader(filename);
print (reader);
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element:
print("element: " + reader.Name); // print the name
print("attribute: " + reader.GetAttribute("name"));
break;
case XmlNodeType.Text: // for text node
print(reader.Value); // read the content of the text
break;
}
}
}
Note: to parse float or int from String, use float.Parse(string), or int.Parse(...) etc
No comments:
Post a Comment