XmlTextReader
In this chapter you will learn:
Read xml file
using System;/*ja v a 2 s . c om*/
using System.Xml;
class XmlTextReaderSample {
[STAThread]
static void Main(string[] args) {
XmlTextReader xmlTextReader = new XmlTextReader("sample.xml");
while (xmlTextReader.Read()) {
if (xmlTextReader.NodeType == XmlNodeType.Element) {
Console.Out.WriteLine((new String(' ', xmlTextReader.Depth * 3)) +
"Name: <" + xmlTextReader.Name + ">; Depth: " +
xmlTextReader.Depth.ToString() + "; Attributes count: " +
xmlTextReader.AttributeCount.ToString() + ";");
}
}
}
}
Next chapter...
What you will learn in the next chapter: