/// <summary> /// Deserialize a HTML document /// </summary> public HDocument DeserializeDocument(TextReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } // Create result HDocument result = new HDocument(); result.Encoding = null; // Load nodes in the document result.Add(Deserialize(reader, err => { if (err is ParseError) { result.AddParseError((ParseError)err); return(true); } return(false); })); // Check encoding if (result.Encoding == null) { if (reader is StreamReader) { result.Encoding = ((StreamReader)reader).CurrentEncoding; } else { result.Encoding = Encoding.UTF8; } } return(result); }
/// <summary> /// Direct serialization of a HTML document to string /// </summary> public String Serialize(HDocument html) { if (html == null) { throw new ArgumentNullException("html"); } return(SerializeNode(html)); }
/// <summary> /// Serialise an HTML document /// </summary> public void Serialize(HDocument html, TextWriter writer) { if (html == null) { throw new ArgumentNullException("html"); } if (writer == null) { throw new ArgumentNullException("writer"); } SerializeNode(html, writer); }
/// <summary> /// Internal document serialization /// </summary> protected virtual void SerializeDocument (HDocument html, TextWriter writer) { SerializeContainer(html, writer); }
/// <summary> /// Create a new HTML document from another. /// </summary> public HDocument(HDocument other) : base(other) { this.Encoding = other.Encoding; }