Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Driver.cs « System.Xml « System.XML « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 80f9cf32934ce8651c5129b5feda589f8d8f6ca8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Driver.cs
//
// Author:
//   Jason Diamond (jason@injektilo.org)
//
// (C) 2001 Jason Diamond  http://injektilo.org/
//

using System;
using System.Xml;

public class Driver
{
	public static void Main(string[] args)
	{
		XmlReader xmlReader = null;

		if (args.Length < 1)
		{
			xmlReader = new XmlTextReader(Console.In);
		}
		else
		{
			xmlReader = new XmlTextReader(args[0]);
		}

		while (xmlReader.Read())
		{
			Console.WriteLine("NodeType = {0}", xmlReader.NodeType);
			Console.WriteLine("  Name = {0}", xmlReader.Name);
			Console.WriteLine("  IsEmptyElement = {0}", xmlReader.IsEmptyElement);
			Console.WriteLine("  HasAttributes = {0}", xmlReader.HasAttributes);
			Console.WriteLine("  AttributeCount = {0}", xmlReader.AttributeCount);
			Console.WriteLine("  HasValue = {0}", xmlReader.HasValue);
			Console.WriteLine("  Value = {0}", xmlReader.Value);
			Console.WriteLine("  Depth = {0}", xmlReader.Depth);

			if (xmlReader.HasAttributes)
			{
				while (xmlReader.MoveToNextAttribute())
				{
					Console.WriteLine("    AttributeName = {0}", xmlReader.Name);
					Console.WriteLine("    AttributeValue = {0}", xmlReader.Value);

					while (xmlReader.ReadAttributeValue())
					{
						Console.WriteLine("      AttributeValueNodeType = {0}", xmlReader.NodeType);
						Console.WriteLine("      AttributeValueName = {0}", xmlReader.Name);
						Console.WriteLine("      AttributeValueValue = {0}", xmlReader.Value);
					}
				}
			}
		}
	}
}