Ejemplo n.º 1
0
        public void Parse(InputSource input)
        {
            var document = new HtmlDocument();

            if (input.Stream != null)
            {
                document.Load(input.Stream, input.Encoding);
            }
            else if (input.Reader != null)
            {
                document.Load(input.Reader);
            }
            else if (input.PublicId != null)
            {
                document.Load(input.PublicId);
            }
            else if (input.SystemId != null)
            {
                document.Load(input.SystemId);
            }

            ContentHandler.StartDocument();

            TraverseNode(document.DocumentNode);

            ContentHandler.EndDocument();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a processor that writes to the file named and may or may not
        /// also output to the screen, as specified.
        /// </summary>
        /// <param name="filename">Name of file to write output to</param>
        /// <param name="printToScreen">Mirror output to screen?</param>
        /// <exception cref="System.IO.IOException"/>
        public XmlEditsVisitor(OutputStream @out)
        {
            this.@out = @out;
            OutputFormat outFormat = new OutputFormat("XML", "UTF-8", true);

            outFormat.SetIndenting(true);
            outFormat.SetIndent(2);
            outFormat.SetDoctype(null, null);
            XMLSerializer serializer = new XMLSerializer(@out, outFormat);

            contentHandler = serializer.AsContentHandler();
            try
            {
                contentHandler.StartDocument();
                contentHandler.StartElement(string.Empty, string.Empty, "EDITS", new AttributesImpl
                                                ());
            }
            catch (SAXException e)
            {
                throw new IOException("SAX error: " + e.Message);
            }
        }