Driver.cs 1.5 KB

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