private void CheckElements(System.Xml.XmlDocument doc, XHtmlMode mode) { if (mode == XHtmlMode.None) { return; } //Select all the nodes System.Xml.XmlNodeList list = doc.SelectNodes("//*"); foreach (System.Xml.XmlElement element in list) { if (mode == XHtmlMode.StrictValidation) { CheckStrictValidation(element); } else if (mode == XHtmlMode.BasicValidation) { CheckBasicValidation(element); } else { throw new ArgumentException("XHtmlMode not supported", "mode"); } } }
/// <summary> /// Check if the html is a valid text using the XML document validator. /// </summary> public bool IsValid(XHtmlMode mode) { try { this.CheckElements(this._xmlDoc, mode); return(true); } catch (Exception ex) { log.Error("Exception occur:", ex); } return(false); }
/// <summary> /// Check if the html is a valid text using the XML document validator. /// </summary> /// <param name="mode"></param> /// <param name="error"></param> public bool IsValid(XHtmlMode mode, out Exception error) { try { CheckElements(mDoc, mode); error = null; return(true); } catch (Exception ex) { error = ex; return(false); } }
private void CheckElements(System.Xml.XmlDocument doc, XHtmlMode mode) { if (mode == XHtmlMode.None) return; //Select all the nodes System.Xml.XmlNodeList list = doc.SelectNodes("//*"); foreach (System.Xml.XmlElement element in list) { if (mode == XHtmlMode.StrictValidation) CheckStrictValidation(element); else if (mode == XHtmlMode.BasicValidation) CheckBasicValidation(element); else throw new ArgumentException("XHtmlMode not supported", "mode"); } }
/// <summary> /// Check if the html is a valid text using the XML document validator. /// </summary> /// <param name="mode"></param> /// <param name="error"></param> public bool IsValid(XHtmlMode mode, out Exception error) { try { CheckElements(mDoc, mode); error = null; return true; } catch (Exception ex) { error = ex; return false; } }