5 public class XmlReaderDumper
7 public static void Main ()
9 new XmlReaderDumper ().TestOASIS ();
12 public void TestOASIS ()
14 XmlDocument doc = new XmlDocument ();
15 foreach (FileInfo fi in
16 new DirectoryInfo (@"xml-test-suite/xmlconf/oasis").GetFiles ("*.xml")) {
18 if (fi.Name.IndexOf ("fail") >= 0)
21 Console.WriteLine (fi.Name);
23 XmlTextReader xtr = new XmlTextReader (fi.FullName);
25 DumpReader (xtr, false);
29 } catch (XmlException ex) {
30 if (fi.Name.IndexOf ("pass") >= 0)
31 Console.WriteLine ("Incorrectly invalid: " + fi.FullName + "\n" + ex.Message);
36 public void DumpReader (XmlReader xr, bool attValue)
38 Console.WriteLine ("NodeType: " + xr.NodeType);
39 Console.WriteLine ("Prefix: " + xr.Prefix);
40 Console.WriteLine ("Name: " + xr.Name);
41 Console.WriteLine ("LocalName: " + xr.LocalName);
42 Console.WriteLine ("NamespaceURI: " + xr.NamespaceURI);
43 Console.WriteLine ("Value: " + xr.Value);
44 Console.WriteLine ("Depth: " + xr.Depth);
45 Console.WriteLine ("IsEmptyElement: " + xr.IsEmptyElement);
47 if (xr.NodeType == XmlNodeType.Attribute) {
48 Console.WriteLine ("Attribute Values::::");
49 while (xr.ReadAttributeValue ())
50 DumpReader (xr, true);
51 Console.WriteLine (":::Attribute Values End");
52 } else if (!attValue) {
53 Console.WriteLine ("Attributes::::");
54 Console.Write (xr.AttributeCount);
55 if (xr.MoveToFirstAttribute ()) {
57 DumpReader (xr, false);
58 } while (xr.MoveToNextAttribute ());
61 Console.WriteLine (":::Attributes End");