File: dumpxml.cs

package info (click to toggle)
semweb 1.05%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,000 kB
  • ctags: 2,832
  • sloc: cs: 14,483; makefile: 176; perl: 20; sh: 11; ansic: 7
file content (32 lines) | stat: -rw-r--r-- 948 bytes parent folder | download | duplicates (3)
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
using System;
using System.Xml;

public class Test {

	public static void Main2(string[] args) {
		XmlDocument doc = new XmlDocument();
		if (true) {
			XmlValidatingReader reader = new XmlValidatingReader(new XmlTextReader(Console.In));
			reader.ValidationType = ValidationType.None;
			doc.Load(reader);
		} else {
			doc.Load(new XmlTextReader(Console.In));
		}
		DumpDoc(doc.DocumentElement, 0);
	}

	public static void Main(string[] args) {
		XmlValidatingReader reader = new XmlValidatingReader(new XmlTextReader(Console.In));
		reader.ValidationType = ValidationType.None;
		while (reader.Read()) {
			Console.WriteLine(reader.NodeType + " " + reader.Name + " " + reader.NamespaceURI);
		}
	}

	static void DumpDoc(XmlElement elem, int indent) {
		for (int i = 0; i < indent; i++) Console.Write("  ");
		Console.WriteLine(elem.Name + " " + elem.NamespaceURI);
		foreach (XmlElement e in elem.SelectNodes("*"))
			DumpDoc(e, indent+1);
	}
}