void Process(SgmlReader reader, string uri) { if (uri == null) { reader.InputStream = Console.In; } else { reader.Href = uri; } if (this.encoding == null) { this.encoding = reader.GetEncoding(); } XmlTextWriter w = null; if (output != null) { w = new XmlTextWriter(output, this.encoding); } else { w = new XmlTextWriter(Console.Out); } if (formatted) w.Formatting = Formatting.Indented; if (!noxmldecl) { w.WriteStartDocument(); } reader.Read(); while (!reader.EOF) { w.WriteNode(reader, true); } w.Flush(); w.Close(); }
void Process(SgmlReader reader, string uri, bool loadAsStream) { if (uri == null) { reader.InputStream = Console.In; } else if (loadAsStream) { Uri location = new Uri(uri); if (location.IsFile) { reader.InputStream = new StreamReader(uri); } else { WebRequest wr = WebRequest.Create(location); reader.InputStream = new StreamReader(wr.GetResponse().GetResponseStream()); } } else { reader.Href = uri; } if (debug) { Debug(reader); reader.Close(); return; } if (crawl) { StartCrawl(reader, uri, basify); return; } if (this.encoding == null) { this.encoding = reader.GetEncoding(); } XmlTextWriter w = null; if (output != null) { w = new XmlTextWriter(output, this.encoding); } else { w = new XmlTextWriter(Console.Out); } if (formatted) w.Formatting = Formatting.Indented; if (!noxmldecl) { w.WriteStartDocument(); } if (testdoc) { XmlDocument doc = new XmlDocument(); try { doc.Load(reader); doc.WriteTo(w); } catch (XmlException e) { Console.WriteLine("Error:" + e.Message); Console.WriteLine("at line " + e.LineNumber + " column " + e.LinePosition); } } else { reader.Read(); while (!reader.EOF) { w.WriteNode(reader, true); } } w.Flush(); w.Close(); }