Driver.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  2. //
  3. // Driver.cs
  4. //
  5. // Author:
  6. // Jason Diamond ([email protected])
  7. //
  8. // (C) 2001 Jason Diamond http://injektilo.org/
  9. //
  10. using System;
  11. using System.Xml;
  12. public class Driver
  13. {
  14. public static void Main(string[] args)
  15. {
  16. XmlReader xmlReader = null;
  17. if (args.Length < 1)
  18. {
  19. xmlReader = new XmlTextReader(Console.In);
  20. }
  21. else
  22. {
  23. xmlReader = new XmlTextReader(args[0]);
  24. }
  25. while (xmlReader.Read())
  26. {
  27. Console.WriteLine("NodeType = {0}", xmlReader.NodeType);
  28. Console.WriteLine(" Name = {0}", xmlReader.Name);
  29. Console.WriteLine(" IsEmptyElement = {0}", xmlReader.IsEmptyElement);
  30. Console.WriteLine(" HasAttributes = {0}", xmlReader.HasAttributes);
  31. Console.WriteLine(" AttributeCount = {0}", xmlReader.AttributeCount);
  32. Console.WriteLine(" HasValue = {0}", xmlReader.HasValue);
  33. Console.WriteLine(" Value = {0}", xmlReader.Value);
  34. Console.WriteLine(" Depth = {0}", xmlReader.Depth);
  35. if (xmlReader.HasAttributes)
  36. {
  37. while (xmlReader.MoveToNextAttribute())
  38. {
  39. Console.WriteLine(" AttributeName = {0}", xmlReader.Name);
  40. Console.WriteLine(" AttributeValue = {0}", xmlReader.Value);
  41. while (xmlReader.ReadAttributeValue())
  42. {
  43. Console.WriteLine(" AttributeValueNodeType = {0}", xmlReader.NodeType);
  44. Console.WriteLine(" AttributeValueName = {0}", xmlReader.Name);
  45. Console.WriteLine(" AttributeValueValue = {0}", xmlReader.Value);
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }